Unit Testing: Prefer Children Over Friends
summary
Advocates replacing test-only friend access with small subclasses that expose just what tests need, using a concrete example: a PlayerStats object that should start at maximum health and zero currency. Notes testing frameworks CxxTest and Catch, warns that friends effectively make privates public, and recommends refactoring into separate Health and Currency classes with public interfaces or using approval tests and legacy-code/TDD practices to get safe, testable units.
AI-written summary · about
chapters (9)
- 0:00Intro
- 0:28About Michael
- 0:45Children and Friends
- 0:59Player Stats
- 1:34Avoid Making Members Public
- 2:31Legacy Testing
- 2:44Using Children
- 3:19Refactoring
- 4:24What I learned








