Properties of Good Tests
From Kent Beck's Test Desiderata — tests should be:
- Isolated — tests MUST NOT share mutable state or depend on execution order
- Composable — tests MUST be runnable in any subset and any order
- Deterministic — tests MUST produce the same result every time, no flakiness
- Fast — milliseconds per unit test, seconds per integration test
- Writable — easy to author, low ceremony
- Readable — a failing test tells you what broke and why
- Behavioral — tests SHOULD verify what the code does, not how it does it
- Structure-insensitive — refactoring internals SHOULD NOT break tests
- Automated — no manual steps, no human judgment needed
- Specific — a failure points to exactly one cause
- Predictive — passing tests mean the code works in production
- Inspiring — confidence to refactor and ship