Clean Test Code
summary
Argues that poorly written tests can be worse than no tests and recommends refactoring legacy code before adding tests. Advocates focused, parameterized unit tests with a Given-When-Then structure (one When only), using parameter arrays for multiple cases, and avoiding brittle UI assertions by using data-selectors and harnesses. Shows practical examples: using a Pact mock server for real HTTP calls against a stubbed provider and a command-handler test asserting three side effects (persist, change context, emit event), and warns that aiming for an arbitrary 80% coverage target is a dangerous anti-pattern.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:07Test code problems
- 8:51Clean test anatomy
- 14:30Layer testing
- 20:55State and acceptance tests
- 23:01Practical test patterns
- 31:16Module and abstraction testing
- 35:30Summary
related talks
41mTesting that the code does what the code does
20mThe Art of Testing
57mAdvanced Testing Techniques: Tips from the trenches
01h 24mPragmatic Not Dogmatic
59mPragmatic unit testing
44mTesting the untestable - patterns and use cases analysis
39mTen things you heard about testing that might be wrong
01h 05mMicrotesting
