principle-testinglisted
Install: claude install-skill lugassawan/swe-workbench
# Testing Strategy and Architecture
Strategy and architecture, not the red-green-refactor discipline. For that, see `principle-tdd`.
## The pyramid
Three tiers, wide base up: **unit → integration → e2e**. Baseline ratio: ~70% unit, ~20% integration, ~10% e2e — adjust toward more integration for infrastructure-heavy systems, more e2e for UI-heavy products.
Inverting the pyramid (heavy e2e, thin unit) produces a slow, brittle suite — e2e tests amplify flakiness and punish every external dependency.
- **Unit** — one class or function, no I/O, milliseconds.
- **Integration** — two or more collaborators, real infrastructure (DB, message bus), seconds.
- **e2e** — full stack through the UI or API gateway; minutes.
Prefer more granular tests. One integration test that exercises a migration is worth more than five e2e tests covering the same path.
## Test doubles
Five kinds (Meszaros's xUnit Patterns taxonomy). State-based: Stub, Fake. Behavior-verification: Spy, Mock. Dummy is a degenerate no-op.
| Double | What it does | When to use |
|--------|-------------|-------------|
| Dummy | Passed but never called | Satisfying required params |
| Stub | Returns canned responses | Isolating the path under test |
| Fake | Working implementation (e.g. in-memory DB) | Fast integration tests |
| Spy | Records calls for post-hoc assertion | Verifying interactions |
| Mock | Pre-programmed expectations; fails on violation | Strict boundary contracts |
**Mock only at trust boundaries**: