Test levels and methods
Test pyramid
The test pyramid is a model for a balanced test suite: many fast unit tests as a broad base, fewer integration tests above them and a few slow end-to-end tests at the top.
Also known as: test automation pyramid
The three layers
- Base: unit tests: numerous, fast, precise in locating defects
- Middle: integration tests: check how components work together
- Top: end-to-end tests: few, but realistic workflows through the whole system
Moving up, relevance to the user increases, but so do run time, effort and instability.
The anti-pattern: the ice-cream cone
Many teams have the pyramid upside down: few unit tests, hardly any integration tests and a large number of manual or UI-driven end-to-end tests. These suites are slow, brittle and expensive to maintain. Defects are found late and are hard to pin down.
And with hardware?
The principle applies to embedded systems too. The base is unit tests and software-in-the-loop on the development machine. Above that come tests on real hardware, and at the top HiL and system tests on the complete device. The more logic can be checked at the bottom, the less scarce test bench time is needed.