They are not unit tests: a survey of unit-testing anti-patterns
summary
Defines a unit as the product’s public interface (functions for libs, endpoints for APIs, widgets for GUIs) and shows concrete fixes: replace brittle 300‑line subtests with focused fixtures, prevent tests from importing internals via import-linter, run real DBs with Docker/testcontainers, cache external calls with VCR.py, speed CI by only running affected tests with pytest-testmon (5k tests → 5 run locally), use dirty-equals + inline snapshots to avoid fragile asserts, and run mutation testing to measure assertion quality.
AI-written summary · about
chapters (13)
- 0:00Introduction and context
- 1:06Redefining unit testing
- 2:44Public interfaces as units
- 5:18Testing pyramids and strategy
- 7:24Test desiderata and design
- 11:55API testing and linter usage
- 14:28Anti-patterns: units and size
- 18:46Assertion strategies and demo
- 26:38Managing coverage and performance
- 29:48Mocking alternatives
- 35:30Mutation testing
- 37:32Fixture management and cleanup
- 40:24Q&A and conclusion
related talks
43mUnselfish Testing
47mThe secret unit testing tools no one ever told you about
01h 02mThe Unit Tests Strike Back: Testing the Hard Parts
44mHow not to test
01h 07mProperties of Unit Tests
21mDon't just test, my friend, test better
44mTesting the untestable - patterns and use cases analysis
37mClean Test Code
