Dirty Tests And How To Clean Them
summary
Java Spring REST API calculator tests start as ~100 lines of duplicated JUnit5 code using RestTemplate and a controller POST to localhost and shrink to a focused suite (~27 tests) by applying extract fields to setup and extract method for HTTP calls, renaming tests to state intent, replacing literals with meaningful constants, introducing a builder for test data, and moving boilerplate into an ApiCallWrapper. The result reads like documentation, isolates failures faster in CI, and produces reusable, less fragile tests.
AI-written summary · about
chapters (8)
- 0:00Start
- 6:50What Is Easy To Maintain
- 15:34What Clean Tests Are
- 16:11Test Show Intent
- 24:43Embedded Constants
- 25:38Example of Api Tests with Spring
- 36:39The Calculator
- 46:30Using Constructors over Builders








