The Science of Unit Tests
summary
Argues unit tests function as small scientific instruments: write tests to falsify “code is correct” hypotheses, not to prove implementations; demonstrates the black-box conundrum with a simple Cup class and shows behavior-driven testing resolves it by exercising observable behaviors rather than internals; recommends concrete tooling: mocks, friend-access white-box hooks only when necessary, test-framework floating‑point comparisons, and mutation testing to calibrate tests; warns about flaky tests, external test servers, and a legacy codebase of half a million lines with only 0.1 unit‑tested.
AI-written summary · about
chapters (22)
- 0:00Welcome and introduction
- 0:51Unit tests and experimental science
- 3:59Rule zero existence of tests
- 4:40Black box testing conundrum
- 7:45White box testing pitfalls
- 11:34Behavior driven development
- 14:21Bugs and falsifiability
- 16:26Empirical science foundations
- 20:19Software as physical system
- 22:06Test driven development as lab technique
- 23:52Calibrating unit tests
- 24:32Brittle tests and error propagation
- 27:19Precision in test results
- 29:05Reproducibility and flaky tests
- 33:55Handling non-determinism
- 38:46Accuracy in testing
- 40:10False positives and negatives
- 43:40Undetected bugs and risks
- 45:03Science to become correct
- 46:29Unit testing as scientific method
- 49:01Summary and call to action
- 49:43Q&A session








