What is test pyramid?
The test pyramid is a model for balancing many fast unit tests, fewer integration tests and a small number of end-to-end tests.
Popularised by Mike Cohn, the pyramid puts unit tests at the wide base, service or integration tests in the middle and UI end-to-end tests at the narrow top, reflecting their relative speed and cost.
Modern tooling has made end-to-end tests cheaper and more stable, so many teams now use a “trophy” or diamond shape with more integration and journey tests than the classic pyramid suggests.
Example
A team has 2,000 unit tests, 300 API tests and 60 end-to-end journey tests. The unit tests cover pricing logic in depth and the E2E tests prove customers can buy.
Best practices
- Test logic at the lowest level that can catch the bug
- Use integration tests for service boundaries
- Reserve E2E tests for critical journeys
- Revisit the balance as tooling changes
Ship without fear.
Start testing free in minutes, or let a QAShift engineer deliver your first morning report within 5 days.