Understanding and implementing the test pyramid
Mike Cohn introduced the test pyramid in his book, Succeeding with Agile, which serves as a visual guide to different testing layers and provides a basic structure for the proportion of tests at each level. Figure 12.1 illustrates the test pyramid with its layers.

Figure 12.1: Test pyramid
The test pyramid contains three layers arranged from bottom to top: unit tests, service (or integration) tests, and E2E tests. The tests at the bottom of the pyramid are more isolated and faster than those at the top, which are more integrated and slower.
The core idea behind the test pyramid is useful when building an effective test suite. The two primary principles should guide our approach:
- Implement tests that vary in scope and focus
- As you move up the pyramid, the number of tests should decrease
To create a balanced, efficient, and maintainable test suite, focus on developing many fast and targeted...