liveBook · Manning

Testing pyramid

As explained in Contract Testing in Action

The test automation pyramid is a model that recommends distributing automated tests across unit, integration, and end-to-end layers, with fewer tests at slower and more expensive higher layers.

The testing pyramid distributes automated tests across unit, integration, and end-to-end layers. It places most tests at the fast, isolated base and fewer tests at slower, more expensive layers, while preserving coverage of integrated behavior and user experience. section 2.1

The layers assign different responsibilities:

  • Unit tests form the largest base and provide speed and isolation. section 2.1
  • Integration tests validate behavior across connected components and environments. section 2.1 section 12.0
  • End-to-end tests verify the user experience but should remain fewer because they are slower and more expensive. section 2.1
  • Contract tests can sit between unit and integration tests, checking expectations between systems without requiring integrated environments. section 2.1.5

Login feature

A login feature can assign null, empty, and overlong credentials to unit tests; authorization and incorrect credentials to contract tests; slow service responses to integration tests; and cookie-session behavior to end-to-end tests. This division gives earlier, more specific feedback without eliminating other test layers. section 2.2

Figure 2.4 The original test automation pyramid comprising three horizontal sections: unit tests, integration tests, and E2E tests
figure

Use the pyramid diagram to compare the relative emphasis of unit, integration, and end-to-end automation. section 2.1

How Contract Testing in Action covers it

How deep it goes
Defines three layers, adds contract testing between unit and integration tests, and contrasts the model with the ice cream cone anti-pattern.
Examples
Uses login validation, authorization, service slowdown, cookie sessions, and contrasting pyramid and ice cream cone diagrams.
What you can do after
Evaluate automated-test placement and distribute failures across unit, contract, integration, and end-to-end checks.
How it connects
Connects unit testing, integration testing, end-to-end testing, contract testing, test automation, and flaky tests.

Also explained in

Compare how 8 books explain testing pyramid →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Contract Testing in Action. The section links point to the parts of the book it draws on.