Files
atelier/domains/testing/first-principles.md
T
2026-08-05 00:22:53 +00:00

44 lines
1.3 KiB
Markdown

# Testing — First Principles
## 1. The Principles
### P1. Tests as Specification
Tests document what the code should do. Reading the tests is reading
the contract.
### P2. Independence
Tests do not depend on each other. Order does not matter. Parallelism
is the default.
### P3. Determinism
Same input, same output, every time. No time, randomness, network, or
filesystem in the test path unless explicitly modeled.
### P4. Fast Feedback
Tests run in seconds, not minutes. Slow tests are skipped, then
deleted.
### P5. Coverage of Behavior
Cover what the code does, not what it is. Lines covered is not the
goal. Behaviors exercised is the goal.
### P6. Failure Specificity
A failing test names the file, the function, the input, the
expectation, and the actual. A test that fails unhelpfully is
broken.
### P7. Realism
Test data resembles production data in shape, distribution, and
edge cases. Toy data hides bugs.
### P8. Maintainability
Tests are first-class code. They are read, reviewed, and refactored.
Test code is not throwaway.
### P9. Edge Case Coverage
Boundaries, nulls, empty sets, maximums, minimums, and invalid inputs
are tested. The middle of the range is the easy part.
### P10. No Test Theater
A test that cannot fail is not a test. A test that asserts nothing
is a lie. Tests earn their place by being able to catch real bugs.