Definition of the test pyramid
The test pyramid distributes a piece of software’s automated tests across several levels. In the article “Test Pyramid” (martinfowler.com, 1 May 2012, read on 12 November 2026), Martin Fowler sees it as a way of building a balanced portfolio of tests. Its essential point: many more low-level unit tests than high-level tests running through the graphical user interface.
A note added on 15 November 2017 traces its origin. The model became known through Mike Cohn’s book “Succeeding with Agile”, published in 2009, which calls it the “Test Automation Pyramid”. According to this note, Mike Cohn had drawn it in 2003 or 2004.
The layers and their names, from one author to another
In “The Practical Test Pyramid” (same website, 26 February 2018), Ham Vocke recalls the three layers of Mike Cohn’s diagram.
| Layer | Name used by Mike Cohn, according to Ham Vocke | Martin Fowler’s reading |
|---|---|---|
| Base | Unit tests | The most numerous tests |
| Middle | Service tests | Tests running through a service layer, such as the API of a web application |
| Top | User interface tests | Tests through the graphical interface: brittle, expensive to write, slow to run |
Ham Vocke takes two ideas from the diagram: write tests of different granularity, and write fewer of them the higher their level. He adds two rules: push each test as far down as possible, and fill in the lower level as soon as a high-level test reveals an error that went unnoticed further down.
In his view, unit tests form a safety net for code changes, the one that refactoring relies on. Neither article puts figures on the distribution.
Ice-cream cone, honeycomb, trophy: competing shapes and criticisms
Martin Fowler uses the image of the ice-cream cone for automation that runs mainly through the interface.
Ham Vocke considers the model too simplistic in hindsight: the term “service test” is poorly understood, and an interface can be checked by unit tests. Martin Fowler recalls the model’s assumption, that broad-scope tests are expensive, slow and brittle: if a team’s broad tests are fast, reliable and cheap to modify, he writes, lower-level tests are not needed.
In “On the Diverse And Fantastical Shapes of Testing” (2 June 2021), he comments on two other shapes, the honeycomb and the trophy, which call for few unit tests and mostly integration tests. He considers the debate pointless: their advocates give “unit test” a narrower meaning than the descriptions of the pyramid do.
Test pyramid, test strategy, business scenario: not to be confused
The pyramid distributes tests by level. The risks to cover are a matter of test strategy. What a suite is worth is measured differently: in common usage, mutation testing checks that the tests detect defects deliberately introduced into the code.
A behaviour-driven development scenario, written with the business, does not automatically belong at the top. Martin Fowler notes that teams confuse end-to-end tests, UI tests and customer-facing tests, three independent characteristics.
A festival ticketing system, layer by layer
Consider a festival’s ticketing system. The pricing rules (reduced rate, multi-day pass, booking fees) are checked case by case, through unit tests. A few tests go through the ordering API. A single journey crosses the interface: buying a ticket and receiving its confirmation. If this journey fails on a fee calculation, the team first writes the missing unit test.
The level to choose for each check is covered in our article on automated testing, the journeys at the top in the one on end-to-end testing. That leaves the overall distribution, which depends on the risks of each application: our software quality and testing page describes the test strategy that sets it.