How to design a test suite you’ll love to maintain
summary
Refactors show concrete rules: move tests into a test package so only public API is exercised; replace magic values (66% becomes an explicit Swedish tax rate) and remove optional fields so tests don’t hide unused inputs; eliminate if-statements in test bodies by supplying expectation helpers and defaults; push price and tax calculations into line-item and tax-rate objects so calculator only coordinates collaborators; use option/builder patterns for concise setup and use mocks to verify calls instead of duplicating return-value assertions.
AI-written summary · about
chapters (18)
- 0:00Introduction to test suites
- 1:44Reviewing test cases
- 4:13Identifying test problems
- 6:00Moving to test package
- 8:28Refactoring assertions
- 10:12Removing if statements
- 11:35Highlighting test differences
- 13:03Reducing boilerplate
- 14:46Builder vs options pattern
- 16:52Refactoring calculator logic
- 18:20Separating concerns
- 19:44Testing price calculation
- 20:45Improving tax rate handling
- 21:49Updating test cases
- 22:30Removing redundant tests
- 23:12Key refactoring constraints
- 24:56Encouraging intentional design
- 26:18Summary and Q&A
