Test strategy & the pyramid

Unit-heavy, integration-middle, E2E-thin — and when the "trophy" shape beats the pyramid. The most common opener in SDET interviews.

About 24 min read3-question knowledge check

The mental model

A test strategy is an insurance portfolio, not a pile of tests. Every test you write is a policy: it costs a premium (authoring time, runtime on every commit, maintenance when the code changes) and pays out when it catches a defect before a user does. The pyramid is the observation that premiums vary by three orders of magnitude across layers — a unit test costs milliseconds per run and almost never lies; an E2E test costs seconds to minutes and fails for reasons that have nothing to do with your code — so a rational portfolio buys most of its coverage at the cheap, reliable layer and reserves the expensive layer for the risks only it can cover.

The shape exists because of what breaks without it. A team that writes only E2E tests (the "ice cream cone" anti-pattern: a fat E2E scoop on top, thin unit base) ends up with a 40-minute suite that fails 1 run in 8 for reasons nobody trusts, so engineers re-run until green, real regressions hide inside the noise, and eventually the suite gets ignored — which is worse than having no suite, because it consumes CI budget while providing false confidence. The pyramid is not an aesthetic preference; it is the economics of feedback loops made visible.

The one idea that explains most strategy arguments: push every check to the lowest layer that can falsify it. If a discount-calculation rule can be proven wrong by a unit test, an E2E test of the same rule adds runtime and flake surface while adding zero new falsification power. E2E tests earn their cost only for what lower layers structurally cannot see: wiring between real components, deployment configuration, and the handful of user journeys whose breakage is an incident regardless of which component caused it.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision