Testing interview question · Most asked

What is the test pyramid, and is it still relevant?

Summary

The test pyramid recommends many fast unit tests, fewer integration tests, and a small number of slow end-to-end tests, because cost and flakiness rise toward the top. It's still a useful guide, though many teams now favor a 'testing trophy' with more integration tests, since they catch wiring bugs that unit tests miss.

Longer Answer

The underlying principle matters more than the shape: get the most confidence per unit of execution time and maintenance cost. Test behavior at the boundary where bugs actually appear, and keep E2E tests for critical user journeys.

Key Points

  • Many unit, fewer integration, few E2E
  • Cost and flakiness rise upward
  • Testing trophy favors integration tests
  • Optimize confidence per cost

Comparison / Tradeoffs

Level Speed Scope Typical tools
Unit ms One function/class pytest, JUnit, Vitest, PHPUnit
Integration ms–s Module + DB/HTTP Testcontainers, TestClient, MockMvc
E2E s–min Full system via UI/API Playwright, Cypress

More most-asked Testing questions

← All Testing questions