Skip to content

Test pyramid

The test pyramid is a heuristic for distributing tests across layers: 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.

Definition

What it is

The concept was popularised by Mike Cohn in Succeeding with Agile (2009), though the drawing of three stacked layers with unit at the bottom had been circulating in the XP community for a few years before. The pyramid is not a rule; it is a diagnostic. A codebase whose test distribution matches the pyramid is easier to maintain, faster in CI, and more resilient to change. A codebase that has inverted the pyramid — heavy on end-to-end, thin on unit — is the "ice cream cone" anti-pattern, and it collapses under CI cost, flakiness and slow debugging.

The pyramid is also a communication tool. When a team argues about "how many tests should this feature have?", the pyramid answers with a rough expectation: twenty new unit tests, five new integration tests, one new E2E test. The numbers are not prescriptive; the ratio is.

Why it matters

Google's most-cited post on the subject, Martin Wacker's "Just Say No to More End-to-End Tests" (2015), recommends the split 70% unit / 20% integration / 10% E2E and identifies the failure mode that the pyramid prevents: E2E suites that grow to hundreds of tests, run for hours in CI, and fail intermittently [1]. Google's own analysis of 4.2 million test runs at the time found that median E2E tests failed intermittently at 1.5% per run; a suite of 500 E2E tests produces 7+ spurious failures per CI cycle, which is where teams stop trusting their tests.

The empirical corroboration comes from GitLab's public test dataset (February 2025). The distribution across the Community and Enterprise editions is 75.66% unit, 15.55% integration, ~9% other — precisely the pyramid shape, at scale (218,459 unit tests against 44,893 integration tests) [2]. The proportion is not decorative; it is the operational shape of a suite that runs in ~30 minutes in CI and stays maintainable.

How it works

graph TD
  E[E2E<br/>5-10% · minutes · full user flows] --> I[Integration<br/>15-20% · hundreds of ms · contract boundaries]
  I --> U[Unit<br/>70-80% · milliseconds · isolated logic]
  style U fill:#E8F5E9
  style I fill:#FFF3E0
  style E fill:#FFEBEE

Three properties of the pyramid matter in practice. Cost scales with height: every layer up is roughly 10× slower and 10× more expensive per assertion, so the lower layers must do most of the work. Confidence scales with height: only the top layer proves that a user can complete a flow, which is why the top layer cannot be eliminated. Feedback latency scales with height: a failing unit test localises to a function in seconds; a failing E2E localises to a user flow in 30-60 minutes of debugging.

Variations and anti-patterns

Shape

Description

When it is legitimate

When it is a smell

Pyramid

70-80 unit / 15-20 integ / 5-10 E2E

Default for most applications

—

Trophy

70 unit / 20 integ / 10 e2e, integ-heavy

API-first services

When E2E creeps up

Ice cream cone

Inverted: heavy E2E, thin unit

Never

Default failure mode of large teams

Hourglass

Heavy unit, heavy E2E, thin integration

Rare, requires contract testing

Missing contract layer

Honeycomb

Many small contract tests

Microservices

Without E2E, user flows untested

The ice cream cone is the failure the pyramid exists to prevent. It emerges when teams add E2E tests as the default for every feature, because "E2E is what the product manager asked for" — and the suite grows to 500 E2E tests over two years because nobody removed the old ones. The remedy is not to delete the E2E tests but to reclassify: many of them are integration tests in disguise (business logic asserted through the UI). Rewriting them at the right layer collapses the runtime and restores the pyramid.

Common failures

Origin

The three-layer drawing appeared in the XP community around 2003-2005, often attributed to early practitioners of the movement. Cohn's Succeeding with Agile (2009) codified it as the canonical reference. The percentages — 70/20/10 — came later, from Google's internal testing team and were published by Wacker in 2015. Since then the pyramid has been the industry's default shape, with legitimate variations emerging for microservices (the honeycomb), API-first (the trophy) and mobile (flattened pyramids where E2E cost dominates).

  1. 2003-2005 — Pyramid drawing circulates in XP community

  2. 2009 — Cohn's Succeeding with Agile codifies the pyramid

  3. 2015 — Wacker/Google publishes the 70/20/10 split

  4. 2018 — "Testing Trophy" (Kent C. Dodds) proposes integ-heavy variant for frontend

  5. 2024 — GitLab publishes 75.66/15.55 split, matching pyramid at scale

Write tests. Not too many. Mostly integration.

— Kent C. Dodds, *Testing Trophy*, 2018 (paraphrase of the practical shift)
2009 · Cohn codifica la pirámide
2015 · Google publica 70/20/10
75,66% · unit en el suite de GitLab (GitLab 2025)
15,55% · integration en el suite de GitLab (GitLab 2025)
1,5% · flakiness por E2E test en Google (2015)
20-50× · coste E2E vs unit

Evidence

FAQ

Are 70/20/10 exact?

No. They are a range. A team with 65/25/10 is healthy; a team with 30/20/50 has inverted the pyramid and should rebalance. The direction of the ratio matters more than the exact numbers.

When can I vary from the pyramid?

For microservices (contract testing can replace E2E), for CLI tools (unit dominates), for data pipelines (integration dominates). The pyramid is the default; legitimate variations exist and are defended with reasoning, not adopted by accident.

How do I fix an inverted pyramid?

Reclassify, do not delete. Many E2E tests are integration tests in disguise (business logic asserted through the UI). Move them to integration; keep the few true E2E flows; add unit tests for the logic that was only covered by E2E.

How long should the whole suite run?

Under 10 minutes for the critical subset (unit + fast integration + a few E2E); under 30 minutes for the full suite. Above 30 minutes, the pyramid needs rebalancing.

Is the trophy replacing the pyramid?

No. The trophy is a frontend variation for component-heavy teams; the pyramid remains the default for backend services and full-stack applications.

Connections

Etymology

Origin: compound

  • test (noun): from Latin testum, "earthen pot"
  • pyramid (noun): from Greek pyramis, "a pyramid"; via Latin pyramis

Semantic network

Test pyramidsoftware-tUnit testIntegratioEnd-to-endContract tTest doubl

● broader ● narrower ● related

Sources