Skip to main content

Test pyramid & coverage

Coverage numbers are necessary but not sufficient — they say the tests ran, not that they assert. This standard sets the shape of the suite and makes mutation testing the arbiter of quality.

The pyramid

Expected ratios, enforced as suite-health checks:

  • Unit — the broad base; fast, isolated, the bulk of assertions.
  • Integration / contract — the middle; real boundaries between components and services.
  • E2E — the thin top; critical user journeys only. Expensive and slower, so kept few and high-value.

A suite that inverts this (heavy E2E, thin unit) is flagged — it's slow, flaky, and hides logic gaps.

Coverage rules

  • Mandatory diff coverage per PR — changed code must meet the threshold; the merge gate enforces it. Whole-repo coverage is a trend, not a gate.
  • Thresholds are floors, risk-adjusted — higher for security- and money-touching code.

Mutation testing — the real arbiter

Mutation testing injects deliberate bugs and checks the tests catch them. The mutation score is the measure an agent can't game by writing high-coverage/no-assertion tests. It runs on changed code and gates the merge. This is the single most important defence against AI-generated tests that verify nothing.

Standards referenced: Fowler's test pyramid; Stryker / PIT (mutation testing).