loom-test-strategy
Test Strategy
Overview
How much to test, at what altitude, and in what order — balancing signal against cost. This file owns the pyramid, coverage goals, risk prioritization, and flaky-test diagnosis. For writing tests and test-double choice see loom-testing; for browser E2E see loom-e2e-testing.
The Pyramid and the Altitude Tradeoff
Push tests down to the cheapest altitude that still exercises the risk. Each layer up costs more to write, run, and debug, and fails for more unrelated reasons.
| Layer | Share | Scope | Speed | Signal on failure |
|---|---|---|---|---|
| Unit | 65-80% | one function/branch, no I/O | ms | precise — points at the defect |
| Integration | 15-25% | real boundary (DB, HTTP, queue) | 10ms-1s | wiring/contract broke |
| E2E | 5-10% | full user journey in a browser | seconds | something broke, somewhere |
⚠ Ice-cream cone anti-pattern: inverted pyramid — many slow E2E tests, few unit tests. Symptoms: hours-long CI, chronic flakiness, "just re-run it" culture, hours to localize a failure. Cause: E2E is easy to start (record-and-play) but the suite becomes unmaintainable. Fix: for every E2E failure, ask "what unit/integration test should have caught this?" and push it down.
⚠ Testing Trophy (Kent C. Dodds) is a legitimate variant for UI/front-end-heavy apps: fewer isolated units, a fat integration middle (component + real collaborators via Testing Library), thin E2E. Choose by where your risk and refactor-churn live — do not cargo-cult 70/20/10.