The test pyramid
Let’s start the discussion about testing along the lines of the test pyramid1 in Figure 8.1, which is a metaphor that helps us to decide on how many tests of which type we should aim for.
1 The test pyramid can be traced back to Mike Cohn’s book Succeeding with Agile from 2009.
Figure 8.1 – According to the test pyramid, we should create many cheap tests and fewer expensive ones
The basic statement of the pyramid is that we should have high coverage of fine-grained tests that are cheap to build, easy to maintain, fast-running, and stable. These are unit tests that verify that a single unit (usually a class) works as expected.
Once tests combine multiple units and go across unit boundaries, architectural boundaries, or even system boundaries, they tend to become more expensive to build, slower to run, and more brittle (failing due to some configuration error instead of a functional error). The pyramid...