Writing tests when the code is already there: Golden Master technique
summary
Explains the Golden Master method: run the untested system, capture inputs and outputs as files, and use those files as the reference before refactoring. Shows practical seams: override randomness by adding a CLI seed argument so outputs become reproducible, run the program across 100 seeds to broaden coverage, and compare new runs to the golden files. Describes building a scraper to convert legacy HTML blog posts to JSON, posting results to the new blog and committing the golden masters to detect regressions.
AI-written summary · about
chapters (10)
- 0:00Introduction to legacy code testing
- 3:13Legacy code challenges and solutions
- 4:39Golden Master technique explained
- 7:33Live coding demo setup
- 9:50Generating the golden master
- 13:25Creating reproducible tests
- 14:16Writing the golden master test
- 16:22Pitfalls and best practices
- 18:06Real-world golden master examples
- 21:16Final thoughts and takeaways
related talks
38mObserving Chance: A Gold Master Test in Practice
38mTest Automation without Assertions
47mTest Automation Without Assertions
45mTest Automation Without Assertions
43mWhat If Documenting Were Enough to Test?
01h 44mTUTORIAL: Refactoring without a net
27mTest Automation without Assertions
01h 01mYou Can Test Anything
