principle-testing
Installation
SKILL.md
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.