📖 Business
Testing Strategy Pyramid
The test pyramid is a model for balancing test types by cost, speed, and confidence. Visualize a pyramid: a wide base of fast, cheap unit tests; a middle layer of integration and service tests; and a small top of slow, expensive end-to-end UI tests. The shape matters — invert it (lots of E2E tests, few unit tests) and you get a slow, brittle, expensive test suite that nobody trusts. Get the shape right and you get fast feedback, targeted coverage, and a pipeline that runs in minutes instead of hours. Humble and Farley place testing strategy early in the book because without reliable automated tests, a deployment pipeline is just a deployment script with extra steps.
2
Minutes
2
Concepts
+45
XP
1
How It Works

The pyramid layers:

Unit Tests (base — widest layer)

  • Test individual functions, classes, or modules in isolation
  • Run in seconds, catch logic errors immediately
  • Should number in the hundreds or thousands
  • No network, no database, no file system — pure logic

Service/Integration Tests (middle layer)

  • Validate interactions between components
  • Test API contracts, database queries, message passing
  • Slower than unit tests but catch integration failures
  • Use test doubles for external dependencies where possible

Acceptance Tests (upper-middle layer)

  • Written in business language, verify business requirements
  • "Given a user with a premium account, when they request a report, then it includes advanced analytics"
  • Run against a deployed application in a staging environment
  • Owned jointly by developers, testers, and business stakeholders

End-to-End / UI Tests (top — smallest layer)

  • Test complete user journeys through the real UI
  • Slowest, most brittle, most expensive to maintain
  • Keep these minimal — only critical happy paths

Nonfunctional Requirement (NFR) Tests

  • Performance, security, capacity, accessibility
  • Run separately because they require production-like environments and load

Rules for all test types:

  1. Fast — the pipeline cannot wait hours for test results
  2. Reliable — no flaky tests. Fix them or delete them.
  3. Deterministic — same inputs produce same outputs, every time