> Markdown version of [/videos/662-write-tests-you-love-not-hate](https://www.wearedevelopers.com/videos/662-write-tests-you-love-not-hate). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Write tests you love, not hate Stop mapping test classes one-to-one with production code. Discover how entity builders and use-case testing transform fragile boilerplate into a lightning-fast engineering workflow. - **Speakers:** [Jens Happe](https://www.wearedevelopers.com/@jens-happe) - **Event:** WeAreDevelopers LIVE - **Published:** September 14, 2023 - **Duration:** 56:49 - **URL:** https://www.wearedevelopers.com/videos/662-write-tests-you-love-not-hate ## Summary Software testing has existed for decades, yet developers often despise the daily practice of writing them due to massive boilerplate, fragile assertions, and painfully slow execution. When tests become a persistent bottleneck, teams inevitably write fewer of them, which drives down code coverage, restricts fearless refactoring, and ultimately invites technical debt. Overcoming this cycle requires treating test creation as a primary architectural concern, shifting the developer experience from a painful chore to a high-speed, confidence-boosting engineering workflow. To create readable and maintainable tests, development teams must aggressively eliminate setup noise. Adopting a strict given-when-then structural pattern drastically improves test comprehension by immediately separating configuration, execution, and verification into intuitive phases. Furthermore, encapsulating test data setup via entity builders—which supply valid default states and hide irrelevant properties—and deploying specific trainer classes to handle repetitive mocking configurations allows developers to define test scenarios at a higher, purer level of abstraction. This strategic encapsulation prevents test files from degenerating into unreadable walls of mock-setup text. A widespread testing anti-pattern is the dogmatic insistence on a strict one-to-one mapping between production classes and test classes, leading to tightly coupled, fragile tests that spontaneously break during routine code restructuring. By shifting focus toward broader, loosely coupled use case tests, developers can freely reorganize internal software layers without continually rewriting assertions. Finally, achieving lightning-fast test execution demands isolating heavy external dependencies like databases and web layers. Embracing principles of clean or hexagonal architecture ensures the core domain remains testable via lightweight dependency injection, transforming a sluggish validation step into a lightweight asset capable of running thousands of execution paths in seconds. **Keywords:** software testing strategies, given-when-then pattern, reducing test boilerplate, entity builders pattern, mock object configuration, fragile test problem, test implementation decoupling, use case testing, clean architecture principles, hexagonal architecture, lightweight dependency injection, test execution speed, fearless code refactoring, technical debt prevention, integration test overhead, TDD ## Chapters 1. **Identifying common challenges in boilerplate test code** (00:05) — Analyzing a complex test method reveals how repetitive mock configurations create unreadable and exhausting code. 1. **How fragile and slow tests compound technical debt** (04:12) — Fragile tests that break on minor code movements discourage test creation and ultimately reduce development velocity. 1. **Improving test readability using structured behavior patterns** (09:38) — Applying the given-when-then pattern logically organizes test setup, execution, and verification phases for clear comprehension. 1. **Reducing fixture setup noise using fluent entity builders** (15:54) — Encapsulating default object attributes within a fluent builder pattern minimizes distractions and highlights relevant test state. 1. **Moving repetitive mock logic into reusable trainer classes** (19:56) — Extracting mocked object configuration into dedicated trainer classes isolates boilerplate away from core test files. 1. **Recognizing tight coupling as the root of fragile tests** (23:48) — Mapping test methods exactly to structural implementation classes forces tests to break during routine refactoring. 1. **Testing broad use cases to support internal code refactoring** (29:30) — Structuring tests around complete use cases rather than single classes allows architectures to evolve without breaking test coverage. 1. **Speeding up test execution by isolating external dependencies** (35:58) — Separating application logic from external layers like databases and web bindings prevents framework latency from slowing down test suites. 1. **Scaling automated testing practices across growing engineering teams** (39:35) — Adopting robust testing conventions gradually transforms codebases with minimal automation into high-performing and reliable systems. 1. **Addressing the costs of integration tests and helper methods** (44:08) — Balancing the architectural tradeoffs between integration tests and isolated unit testing ensures sustainable performance in large test suites. ## Related Moments - [Adopting test-driven design as a strategic development methodology](https://www.wearedevelopers.com/videos/446-treat-yourself-a-tale-about-dog-training-and-test-driven-development) (from "Treat yourself - A tale about dog training and test-driven development") - [Reflecting on the core motivations for writing tests](https://www.wearedevelopers.com/videos/1678-the-2025-state-of-javascript-testing) (from "The 2025 State of JavaScript Testing") - [Applying key software design rules to test code](https://www.wearedevelopers.com/videos/515-dirty-tests-and-how-to-clean-them) (from "Dirty Tests And How To Clean Them") - [Reviewing the benefits of clean test refactoring](https://www.wearedevelopers.com/videos/515-dirty-tests-and-how-to-clean-them) (from "Dirty Tests And How To Clean Them") - [Treating unit tests as essential development tools](https://www.wearedevelopers.com/videos/1642-how-unit-testing-saved-my-career) (from "How Unit Testing Saved My Career") - [Weighing the benefits and tradeoffs of test-driven development](https://www.wearedevelopers.com/videos/114-why-you-must-use-tdd-now) (from "Why you must use TDD now!") ## Related Articles - [How to Avoid Over-Engineering](https://www.wearedevelopers.com/magazine/546-how-to-avoid-over-engineering) - [Get Old, go Slow, Write Code!](https://www.wearedevelopers.com/magazine/81-get-old-go-slow-write-code) - [Ignore the Hype: How to Avoid Being Deceived by Technological Trends](https://www.wearedevelopers.com/magazine/528-ignore-the-hype-how-to-avoid-being-deceived-by-technological-trends) - [How to create a test plan for software testing](https://www.wearedevelopers.com/magazine/56-how-to-create-a-test-plan-for-software-testing) ## Related Jobs - [Software Tester (f/m/d)](https://www.wearedevelopers.com/jobs/44712-software-tester-f-m-d) at **Power Plus Communications** - [Software Tester](https://www.wearedevelopers.com/jobs/ext/1209689-software-tester) at **BWI GmbH** - [Engineer, Offensive Security Organization](https://www.wearedevelopers.com/jobs/ext/1992296-engineer-offensive-security-organization) at **Twilio** - [Test Engineer](https://www.wearedevelopers.com/jobs/ext/1872489-test-engineer) at **ZEISS Group** - [SENIOR SOFTWARE-ENTWICKLER:IN (W/M/D)](https://www.wearedevelopers.com/jobs/48210-senior-software-entwickler-in-w-m-d) at **Pradtke GmbH** - [Staff, Analytics Engineer](https://www.wearedevelopers.com/jobs/ext/569504-staff-analytics-engineer) at **Twilio**