Writable Tests
Tests should be cheap to author relative to the code they test. Beck’s vocabulary, kept with a caveat: most of the field treats writability as emergent rather than a goal you aim at directly. The principle behind it is “listen to the tests” from Freeman and Pryce: a test that is hard to write is design feedback; the production code is telling you it has too many dependencies or does too much.
So treat this property as a gauge, not a lever: when authoring cost climbs, fix the design (or reach for builders), don’t lower the testing bar. The tempting shortcut, mocking every collaborator, makes a test cheap to write but couples it to structure, so it trades against Structure-Insensitive, one of the trade-offs among the properties.
Part of Test Desiderata.
Measuring: a trend, not a threshold. Watch time-to-first-test for a new module, and setup lines per test.
Sources
- Kent Beck, Test Desiderata: the Writable property.
- Freeman and Pryce, Growing Object-Oriented Software: “listen to the tests”, authoring cost as design feedback.