The Test Pyramid & Quadrants — What to Automate First
As a manual tester, your instinct is to test through the screen — that's what a user sees. Automation asks you to flip that instinct, and this lesson shows you why in one simple picture.
The idea, in one line
Catch each bug at the cheapest place that can catch it. That's the whole rule. The picture that explains it has a proper name interviewers use — the test pyramid — so it's worth knowing.
Why that shape?
The shape is really about cost. Here's what each layer costs you:
- Unit tests run in milliseconds, point straight at the broken function, and rarely give false alarms.
- End-to-end tests are slow, break easily, and when they fail they only tell you something broke somewhere.
- So you write lots of the cheap ones and very few of the expensive ones.
See it work
A healthy test suite mirrors the pyramid: many unit, some service, few end-to-end. Here's a quick way to check the balance.
# Count of tests at each layer
suite = {"unit": 420, "service": 60, "e2e": 12}
total = sum(suite.values())
unit_share = suite["unit"] / total
print(f"unit share: {unit_share:.0%}") # unit share: 85%
# Warning sign: if e2e outnumbers unit, the pyramid is upside down
assert suite["unit"] > suite["e2e"], "top-heavy: push tests down"
# Same bug, cheapest layer that catches it wins:
catches = {"discount math": "unit", "api contract": "service", "checkout flow": "e2e"}
for bug, layer in catches.items():
print(f"{bug:14} -> test at: {layer}")Read it top to bottom: you counted your tests, checked the shape wasn't upside down, then matched each kind of bug to the cheapest layer that can catch it.
Advanced — the trap and the wider map
The classic mistake is the ice-cream cone: a fat layer of screen tests balancing on almost no unit tests. It feels thorough, but it's slow and flaky — and it's exactly the shape a manual tester builds by default. If your top layer is bigger than your bottom, that's the warning.
There's also a companion map called the testing quadrants. It sorts checks by two questions: does this check help the team build or critique the finished product, and is it technical or business-facing? Its main lesson: not everything belongs in automation — some checks are still done by a human.
Grounded in Martin Fowler's 'The Practical Test Pyramid' (martinfowler.com)
All lessons in Testing Fundamentals, Reframed for Automation
- The Test Pyramid & Quadrants — What to Automate First
- Boundary Values & Equivalence Partitioning as Automation Inputs
- Decision Tables & State Transitions
- Risk-Based Testing — Deciding What NOT to Automate
- Shift-Left, Shift-Right & Your 1-Page Test Strategy