liveBook · Manning

Testing pyramid

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

The testing pyramid is a model that organizes tests into layers, with broader and generally slower tests placed above narrower and generally faster tests.

The testing pyramid balances test coverage and feedback speed: keep many fast unit tests at the base, fewer integration tests above them, and still fewer end-to-end tests at the top. section 9.4

Use each layer for a different scope:

  • Unit tests exercise a small function or code unit in isolation, often with mocked dependencies. section 9.12
  • Integration tests exercise a whole microservice through its normal interface, such as HTTP requests or messages. section 9.12
  • End-to-end tests exercise groups of microservices or the full application, including the frontend. section 9.4

A practical microservices stack

Run unit and integration tests with Jest, use its --watch or --watchAll flags for rapid feedback, start a cut-down application with Docker Compose, and drive the frontend with Playwright for end-to-end tests. Connect the suite to CI/CD so failures warn before production. section 9.12 section 9.4

Figure 9.1 The testing pyramid indicates the relative amounts of each type of test we should have.

Use the diagram to compare the relative amounts of unit, integration, and end-to-end tests in a suite. section 9.4

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Defines three testing levels, their relative quantities, interfaces, and tools, but does not detail test implementation beyond these practices.
Examples
Uses isolated functions, whole microservices, HTTP or message interfaces, and a Docker Compose application tested through a frontend.
What it assumes
Assumes an automated-testing context while defining unit, integration, and end-to-end testing from their basic purposes.
What you can do after
Apply via Jest, Docker Compose, Playwright, and CI/CD to build layered automated tests with rapid local feedback.
How it connects
Connects unit testing, integration testing, end-to-end testing, mocking, microservices, Docker Compose, Jest, Playwright, and CI/CD.

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 Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.