Visual walkthrough — Testing — unit, integration, system, acceptance, smoke, regression
We will earn every symbol before we use it. By the end you will be able to explain, from a blank page, why smart teams pour effort into tiny cheap tests instead of a few grand ones.
Step 1 — What is a "stage"? Draw the assembly line
WHAT we do here: lay out the stages left-to-right as a conveyor belt, so "escaping a stage" becomes a concrete picture — the part rolling one station further before anyone inspects it.
WHY start here: the whole result depends on counting how many stations a bug rides through before it is caught. We can't count until we can see the stations.
PICTURE: the belt below has four stations. A defective gear (coral) sits at the first station. Each arrow to the right is one escape.

The number we will care about is: how many arrows did the gear cross before someone pulled it off the belt? Call that number .
Step 2 — What does one escape cost? The multiply, not the add
WHAT we do: attach a starting price to the freshly-born bug and ask what one escape does to that price.
WHY multiply and not add? If escaping added a flat \5$ each time, cost would be a gentle straight line. But real re-work compounds: the later stage contains everything the earlier one did, plus its own overhead — so each step multiplies the previous cost by roughly the same factor. Multiplying-by-a-constant-each-step is exactly what we draw next.
PICTURE: two ladders side by side — the left one adds a fixed rung height (a straight climb), the right one multiplies (each rung taller than the last). Real bug cost is the right ladder.

Step 3 — Build the cost after each escape, one station at a time
WHAT we do: apply the multiply rule step by step and record the running cost. This is the heart of the derivation.
WHY step by step: we want the reader to see the pattern form, not be handed a formula. Each line below is "take the previous cost, multiply by ."
PICTURE: the bug rides the belt; above each station we stack the cost as a growing bar (mint → butter → coral), each bar exactly times taller than the one before.

Now read the growing cost, station by station:
Annotating the last term :
- — the original tiny birth-cost, still sitting there as the base.
- — the multiplier applied three times, once for each of the 3 stations the bug crossed.
- The exponent is literally , the arrow-count from Step 1. That is the whole trick.
Step 4 — Generalise: the formula falls out by induction
WHY it's a proof, not a guess: each transition is defined as "multiply by ." Start at . Assume after stages the cost is (this is true for above). Then one more escape multiplies once more: — which is the same rule with . Since it holds for the next whenever it holds for the current , it holds for all . That's induction.
PICTURE: the same bars from Step 3, now plotted as a smooth exponential curve — flat and cheap on the left, rocketing upward on the right. With , three escapes = the birth-cost.

Step 5 — The degenerate cases (don't skip these)
Case (caught instantly): . Good — a bug caught the moment it's written costs exactly its birth-price, nothing extra. The formula didn't accidentally inflate it.
Case (no penalty per stage): for every . This is the imaginary world where escaping a stage costs nothing extra — the curve goes flat. If that were reality, testing early wouldn't matter. The pyramid exists precisely because .
Case "add instead of multiply" (the wrong model): if cost merely added each stage, — a straight line, only after 3 stages, not . Comparing the line to the curve shows why the multiply model is the scary (and realistic) one.
PICTURE: all three plotted together — the flat line (), the gentle straight line (additive), and the exploding curve (). One glance shows which world we live in.

Step 6 — Turn the curve into the pyramid shape
WHAT we do: map each test type to its (how far up the belt it catches bugs) and to its cost per test. Then let the number of tests you should write be inversely tied to cost.
WHY this produces a pyramid: cheap-to-catch () tests let you afford many; expensive-to-catch (high ) tests you can only afford few. Wide base, narrow top — the shape isn't a decoration, it's the cost curve flipped on its side.
PICTURE: the exponential cost curve on the left; its mirror — the classic test pyramid — on the right, wide unit base in mint, thin system/acceptance cap in coral.

Step 7 — Bonus: why the top of the pyramid must stay tiny (flakiness)
WHY multiply the probabilities? If the tests are independent — one's outcome tells you nothing about another's — then "all correct" means this one right AND that one right AND …. Independent ANDs multiply. So:
- — per-test reliability, sitting under the product.
- — how many times we multiply, i.e. suite size.
- — shrinks fast because (multiplying by less-than-one repeatedly heads toward zero).
PICTURE: plotted against for a flaky — it slides from near-1 down through the danger zone by .

The one-picture summary
Everything above, compressed: the bug rides the belt (top), the cost explodes as (middle-left), the shape flips into the pyramid (middle-right), and flakiness warns you to keep the top thin (bottom).

Recall Feynman retelling — say it back in plain words
Imagine a broken gear on a conveyor belt. Every station it slides past before someone spots it makes the fix about ten times harder, because now more people and more re-joined parts are involved. So the price isn't "a little more each time" — it multiplies: one dollar, then ten, then a hundred, then a thousand after three stations. Written down, that's : the seed price , multiplied by the ten-fold factor once for each station it escaped. Because catching a bug at the very first station (the "unit" station) is dirt cheap, and catching it at the last station is brutally expensive, you naturally want tons of cheap early checks and only a few expensive late ones. Draw that as a stack and you get a wide-bottomed pyramid — not because someone liked triangles, but because that's the cost curve tipped on its side. And there's a second warning: big end-to-end tests occasionally lie (they're flaky). If each is right of the time, running of them means the whole suite is trustworthy only of the time, because you're multiplying by itself times. So keep the flaky ones few — another reason the pyramid stays skinny on top.
Recall Quick self-check
Cost of a bug caught with 0 escapes? ::: — just the birth price. Why multiply by per stage instead of adding? ::: Re-work compounds; each later stage contains all earlier work plus new overhead. With c=\1,k=10$1\cdot10^{3}=$1000k=1n=500p=0.9990.999^{500}\approx 0.61nn$ catches → afford few. Wide base, thin top.
Prerequisites & neighbours: Defect Cost of Delay · Code Coverage · Continuous Integration · Verification and Validation · Mocks Stubs and Fakes · Test-Driven Development (TDD) · Behaviour-Driven Development (BDD) · back to the parent topic.