Code Coverage Numbers
5 exercises — read coverage reports accurately, discuss coverage drops, understand line vs branch coverage, and communicate about test debt in professional English.
Coverage quick reference
- Line coverage — % of code lines executed by tests
- Branch coverage — % of if/else paths exercised
- Coverage threshold — minimum % required for the build to pass
- Test debt — untested code that accumulates over time
- Coverage ≠ correctness — high % doesn't prove the code works correctly
0 / 5 completed
1 / 5
A CI pipeline output shows:
Test Coverage Report
Overall: 67.3% (threshold: 80%)
Changed files: 4
src/auth/jwt.ts 38.2%
src/auth/session.ts 51.6%
src/api/users.ts 94.1%
src/utils/hash.ts 88.7%
How would you summarise this for a pull request comment?
Test Coverage Report
Overall: 67.3% (threshold: 80%)
Changed files: 4
src/auth/jwt.ts 38.2%
src/auth/session.ts 51.6%
src/api/users.ts 94.1%
src/utils/hash.ts 88.7%
How would you summarise this for a pull request comment?
The best answer identifies:
1. The exact threshold breach (67.3% vs 80%)
2. The consequence (build blocked)
3. WHERE the gap is (auth module, not utils/api)
4. The risk context (security-critical files justify prioritising them)
Why this matters:
• `src/api/users.ts` at 94.1% is fine — no action needed
• `src/utils/hash.ts` at 88.7% is fine
• The problem is entirely within `src/auth/` — this is precisely where you WANT coverage because auth bugs = security vulnerabilities
Key vocabulary:
• code coverage — the percentage of code lines/branches executed by the test suite
• coverage threshold — the minimum coverage required to pass the build (configured in Jest, Pytest, etc.)
• block the build — prevent the CI pipeline from succeeding
• coverage gap — the difference between current coverage and the threshold
• security-critical — code where bugs would have security consequences
Common coverage tools: Jest (JS/TS), Istanbul/nyc (JS), pytest-cov (Python), JaCoCo (Java), SimpleCov (Ruby)
1. The exact threshold breach (67.3% vs 80%)
2. The consequence (build blocked)
3. WHERE the gap is (auth module, not utils/api)
4. The risk context (security-critical files justify prioritising them)
Why this matters:
• `src/api/users.ts` at 94.1% is fine — no action needed
• `src/utils/hash.ts` at 88.7% is fine
• The problem is entirely within `src/auth/` — this is precisely where you WANT coverage because auth bugs = security vulnerabilities
Key vocabulary:
• code coverage — the percentage of code lines/branches executed by the test suite
• coverage threshold — the minimum coverage required to pass the build (configured in Jest, Pytest, etc.)
• block the build — prevent the CI pipeline from succeeding
• coverage gap — the difference between current coverage and the threshold
• security-critical — code where bugs would have security consequences
Common coverage tools: Jest (JS/TS), Istanbul/nyc (JS), pytest-cov (Python), JaCoCo (Java), SimpleCov (Ruby)