intermediate
Test pyramid and risk-based coverage
Use the pyramid as a feedback heuristic: many fast deterministic checks, fewer cross-boundary tests, and targeted E2E flows for business risk.
The test pyramid is a feedback heuristic, not a quota: many fast unit checks at the base, fewer integration tests across real boundaries, and a thin cap of E2E flows for business-critical journeys. Risk-based coverage means you invest where failure is expensive—payments, auth, data loss—not where code is merely voluminous.
/ E2E \
/-------\
/ Integr. \
/-----------\
/ Unit \
Balance speed with confidence: units give pinpoint failures; integration catches wiring mistakes; E2E proves the product works for users.
On interviews: explain why an inverted pyramid (many slow UI tests) creates flaky CI and slow feedback, and how you would reprioritize by risk.
Common pitfalls: treating pyramid ratios as law, skipping integration because units pass, or running full E2E for every edge case.
The trade-off is faster feedback versus broader confidence—more E2E increases certainty but multiplies maintenance and flake.
Checklist:
- Name the three layers and what each catches.
- Tie coverage to business risk, not line coverage alone.
- Describe how you would shrink a bloated E2E suite.