Test Pyramid
What is Test Pyramid?
The test pyramid, introduced by Mike Cohn and popularised by Martin Fowler, is a visual model for distributing automated test effort. The three layers in mobile: Unit tests (fast, isolated, no device required, business logic, parsers, formatters), Integration tests (moderate speed, test component boundaries, database queries, network layer, ViewModels), and UI/E2E tests (slow, device-dependent, test full user flows). The pyramid shape represents the recommended proportion: many units, fewer integrations, fewest E2E tests. Inverting the pyramid, many E2E tests, few units, is the 'ice cream cone' anti-pattern: expensive to run, slow to fail, hard to debug.
Related terms
Test Pyramid, frequently asked questions
Unit tests (bottom): fast, isolated logic tests with no device. Integration tests (middle): tests that cross component or layer boundaries, database, API client, ViewModel. UI/End-to-End tests (top): full-app tests on simulator or real device that exercise complete user flows. The pyramid recommends investing most effort in the bottom layer and least in the top.
The ice cream cone is the inverted test pyramid: a codebase dominated by slow, fragile UI tests with minimal unit test coverage. This pattern produces suites that take hours to run, fail for non-code reasons (flakiness, environment issues), and give poor diagnostic signal because failures require full UI reproduction to debug.