Code Coverage Principle

lesson workflow archived workflow/code-coverage-principle.md View on GitHub

Code Coverage Principle

Rule

Pursue code coverage improvements strategically, focusing on bug prevention and refactoring safety, not metric improvement.

Context

When considering test coverage work during autonomous operation or task selection.

Detection

Observable signals indicating poor coverage task selection:

Pattern

Evaluate coverage work using three key questions:

Question 1: Would this test catch a real bug?
Question 2: Are we refactoring code that needs a safety net?
Question 3: Is there higher-priority work available?

YES to 1 or 2, NO to 3 → Pursue coverage work ✓
NO to 1-2, or YES to 3 → Deprioritize coverage work ✗

Real-world decisions:

Bug found in uncovered code → Add tests ✓ (prevents regression)
Refactoring complex logic → Add tests first ✓ (safety net)
Feature needs CI confidence → Add tests ✓ (catch regressions)
Simple getter/setter forgotten → Skip tests ✗ (low value)
"Just improving metrics" → Skip work ✗ (not strategic)
Higher-value issues blocked → Skip coverage ✗ (prioritize blockers)

Outcome

Following this principle enables:

Related

Match Keywords

add tests test coverage write tests for pytest coverage missing tests