practice

Test Pyramid

A distribution of tests weighted towards many fast unit tests, fewer integration tests, and very few slow end-to-end tests.

testingciquality

The shape follows from cost. A unit test runs in milliseconds and tells you precisely what broke. An end-to-end test runs in minutes, needs an environment, and tells you only that something broke. Inverting the pyramid produces a suite that is slow, flaky and diagnostically useless — the "ice cream cone".

For distributed systems the important addition is contract tests, which sit between unit and end-to-end: each consumer declares what it expects of a provider, and the provider's build verifies it can satisfy every consumer's expectations. This catches integration breakage without needing all services running together, which is the specific problem end-to-end tests are usually deployed to solve badly.

Architectural relevance: if a design can only be tested end-to-end, that is a signal the boundaries are wrong.