Summary
The test pyramid, introduced by Mike Cohn, describes an ideal balance of automated tests: many fast unit tests at the base, fewer integration tests in the middle, and a small number of end-to-end tests at the top.
What is the Test Pyramid?
The test pyramid is a visual metaphor for structuring a test suite. The wide base represents unit tests—cheap, fast, and numerous. The middle tier represents integration tests that verify how components work together. The narrow top represents end-to-end or UI tests that exercise the full system but run slowly and are costly to maintain.
Inverting the pyramid—relying heavily on end-to-end tests—leads to slow CI pipelines, brittle tests, and poor developer feedback loops. The pyramid guides teams toward a cost-effective mix.
The model has been extended over time: some teams add a service or API test layer between integration and E2E, reflecting microservices architectures where contract and API tests play a large role.
Why is the Test Pyramid relevant?
- Cost efficiency: Unit tests are cheapest to write and maintain; the pyramid minimises over-reliance on expensive E2E tests
- Speed: A pyramid-shaped suite keeps CI feedback fast by maximising unit tests
- Risk coverage: Each layer catches different classes of bugs, providing layered confidence