âBeyond Coverage: Test Quality for the Agentic Loopâ - Part 1 of 7. There is no single âtest qualityâ number - this part lays out the whole catalog as a stack of four layers, each answering a different question. Part 0 established why coverage lies; this is the map of what to measure instead.
How to think about it: four layers, four questions
| Layer | Question it answers | Primary metrics | Indicator type |
|---|---|---|---|
| 1 · Reachability | Did the test even run this code? | Line/statement, branch/condition, MC/DC coverage | Negative only (low = bad; high â good) |
| 2 · Effectiveness â | Would the test notice if the code were wrong? | Mutation score, assertion density & quality, test-smell freedom | Positive - this is âgoodâ |
| 3 · Risk targeting | Are the changed and critical parts tested? | Diff/changed-line coverage, critical-path coverage, property-based testing | Positive (scoped) |
| 4 · Trust & health | Is the signal reliable enough to gate a merge? | Flakiness rate, suite speed, determinism, pass-on-rerun | Gate prerequisite |
No single number is âtest quality.â Read the suite as four layers, and gate bottom-anchored.
You build up the stack and you gate bottom-anchored: fix the coverage zeros, then prove oracle strength, then aim it at the diff and critical paths, and only trust it to gate merges once itâs reliable.
Layer 1 - Reachability (coverage family)
- Line / statement coverage - % of statements executed. Coarsest. Easiest to game.
- Branch / condition coverage - % of decision outcomes (true and false) executed. Stronger than line, still execution-only. Recall: it agrees with mutation on only ~47% of classes (Part 0).
- MC/DC (Modified Condition/Decision Coverage) - each boolean sub-condition independently shown to affect the outcome. Mandated in safety-critical avionics (DO-178C). Strong structurally, but still answers only âwas this exercised?â, not âwould a wrong result be caught?â
Use: negative indicator + the denominator that tells mutation tools where itâs even worth placing mutants.
Layer 2 - Effectiveness (the oracle layer) â
This is the heart. These metrics measure whether the assertions can catch a regression.
- Mutation score - inject small faults (âmutantsâ) into the code; the score is the % the test suite kills (detects via a failing test). This is the most direct proxy for âwould my tests catch a bug here?â Full treatment in Part 2. Note the honest nuance: mutation score is a powerful diagnostic of oracle strength, but not a magic standalone predictor of real-world faults - see Part 3.
- Assertion density - assertions per test. A blunt but useful smoke alarm: a test with zero assertions verifies nothing (an Assertion-Free Test smell), yet still counts toward coverage. Density alone is gameable (you can add weak asserts), so pair it with mutation score.
- Assertion quality - do assertions check behaviour (the intended output/contract) or implementation (incidental internals)? A strong oracle âdetects deviations from intended program behaviourâ; correctness (no false alarms) and strength are orthogonal - a correct oracle can still be weak. [oracle]
- Test-smell freedom - absence of the well-catalogued smells that quietly destroy
fault-detection:
- Assertion-Free Test / Empty Test - no verification. An empty test is âmore dangerous than not having a test at allâ because the framework reports it as passing. [smells]
- Test Tautology - assertions logically predetermined to pass.
- Assertion Roulette - many unlabeled asserts; on failure you canât tell which broke.
- Eager Test - one test exercises many behaviours, so a failure is ambiguous.
- Mystery Guest / Magic Number Test / Conditional Test Logic / Sleepy Test (arbitrary
sleep). The canonical catalog lists ~19 types. [smells]
Layer 3 - Risk targeting
Effectiveness is expensive; spend it where it matters.
- Diff / changed-line coverage - of the lines this PR changed, how many are tested? The single most practical day-to-day gate, and the natural unit for a legacy codebase (you donât need the whole repo green - just the diff).
- Critical-path coverage - explicit, high-strength testing of money/auth/data-loss paths. In a typical fintech domain: money calculation, a scheduled payment run, idempotency, due-date rules.
- Property-based testing - instead of fixed examples, assert invariants over generated
inputs (Go:
testing/quick,gopter,rapid; .NET:FsCheck,CsCheck). A strong quality signal because it forces you to state what must always be true, and it explores inputs youâd never hand-pick. Excellent for money math: âtotal paid never exceeds amount owed,â ârounding never loses a cent.â
Layer 4 - Trust & health
A suite can be effective and still untrustworthy as a gate.
- Flakiness rate - % of tests with non-deterministic pass/fail. A flaky gate is no gate: it trains humans (and agents) to retry until green, which silently disables the protection. Metaâs pipeline explicitly re-runs candidate tests 5Ă and discards any that arenât stable. [testgen]
- Suite speed / health - if the gate takes hours, it wonât run on every PR. Diff-scoped runs keep it in minutes.
- Determinism - no dependence on wall-clock, ordering, network, or shared state. (Directly
relevant to any
DateTime.Now/ due-date logic - ambient time is the classic flakiness source.)
What this means for âdid I write enough tests?â
Stop asking âwhatâs my coverage %?â Ask, per module, in this order:
- Are there coverage zeros on changed/critical code? (Layer 1 - cheap to find.)
- Do surviving mutants exist on those lines? i.e., can I break the code and have tests still pass? (Layer 2 - the real answer.)
- Are the assertions behavioural, and free of smells? (Layer 2.)
- Is the diff and the money-path covered with strong oracles? (Layer 3.)
- Is the suite fast and flake-free enough to trust unattended? (Layer 4.)
A âgood enoughâ legacy suite is one where, for the code youâre changing, the answers are no zeros, few survivors, behavioural asserts, no flakes. That is the precondition for the agentic loop - quantified in Part 6.
The layer that decides âgood,â Layer 2, deserves its own close look. Mutation score is the sharpest instrument we have for it, and Part 2 is a proper explanation of how it actually works.
Sources
- [smells] testsmells.org catalog & test-smell catalog. https://testsmells.org/pages/testsmells.html · https://test-smell-catalog.readthedocs.io/en/latest/
- [oracle] Test oracle strength vs. correctness (orthogonality), arXiv 2405.x. https://arxiv.org/html/2405.03786
- [testgen] Alshahwan et al., Automated Unit Test Improvement using LLMs at Meta (TestGen-LLM), FSE 2024. https://arxiv.org/abs/2402.09171
- [oraclegap]/[branchcov] see Part 0 sources.
â Previous: Part 0 - Why Coverage Lies · Next: Part 2 - Mutation Testing, Properly Explained â
The series - Beyond Coverage: Test Quality for the Agentic Loop: 0 · Why Coverage Lies · 1 · The Metric Catalog (you are here) · 2 · Mutation Testing, Properly Explained · 3 · What the Empirical Research Actually Says · 4 · Tooling for Go and .NET · 5 · Grading AI-Generated Tests · 6 · The Readiness Rubric