This loop grows test coverage incrementally instead of in one risky batch.
The cycle measures current coverage, picks the least-covered, highest-risk module, writes tests focused on real behavior, re-runs the suite, and repeats.
It stops when coverage reaches the target (for example, 90%), everything passes, and no new test is flaky.
The idea is to cover branches, error paths, and edge cases, never gaming the metric with empty assertions.
When to use
- When coverage is low and you want to raise it safely.
- To prioritize the riskiest, least-tested code first.
- When you want real tests, not inflated numbers.
How to use
Run the loop asking it to measure coverage, cover the highest-risk module with real tests, re-run the suite, and continue until it hits the target with everything green.