Minimal Test Data
Bache’s Minimal Data: use the smallest, simplest data that exercises the behavior under test. This garden reads it as the descendant of what Meszaros called the Minimal Fixture, though the mapping is the garden’s own: Bache names neither Meszaros nor the fixture. Rainsberger’s test is the sharpest: if you can change a value without changing the result, it’s irrelevant data, and irrelevant data actively hurts, because every reader must first figure out which fields matter.
The Test Data Builder pattern (Freeman and Pryce) is the standard lever: sensible defaults, per-test overrides for the one or two values the behavior turns on. Serves both Fast and Readable.
Part of Test Desiderata.
Measuring: fixture-read coverage (fields the test never reads are bloat) and fixture-size trend over time.
Sources
- Emily Bache, Test Desiderata 2.0: promotes Minimal Data to a named property.
- Gerard Meszaros, Minimal Fixture: the original pattern.
- Freeman and Pryce, Growing Object-Oriented Software: the Test Data Builder.
- J.B. Rainsberger, What Your Tests Don’t Need to Know Will Hurt You: irrelevant data is any value you can change without changing the result.