What is the test pyramid?
- Technology:
- Software Testing
Quick answer
The test pyramid is a guideline to have many fast unit tests at the base, fewer integration tests in the middle and only a small number of slow end-to-end tests at the top, so the suite stays fast and reliable.
Detailed explanation
The shape reflects cost and speed. Lower-level tests are cheap to write and run and give precise failures; higher-level tests give more realistic confidence but are slower and break for more reasons.
The anti-pattern is the "ice-cream cone": most coverage comes from manual testing and UI tests, with few unit tests. Such suites take hours, fail randomly, and teams stop trusting them.
The pyramid is a heuristic, not a law. Some teams prefer a "testing trophy" with more integration tests, especially for frontend code where testing components with their real children gives better confidence per test. The underlying principle is the same: push each check to the lowest level that can catch the bug.
Key points
- Many unit tests, fewer integration tests, few end-to-end tests
- Avoid the ice-cream cone of mostly UI and manual tests
- Test each behaviour at the lowest level that can catch the bug