9to5 coverage · Guides
How to fix a failing patch coverage check
Find the missing behavior, add focused tests, and verify coverage on the correct pull request commit.
1. Confirm what failed
Open the patch check and verify the repository, PR number and uploaded commit SHA. A passing local suite cannot update a report for an older commit. Check whether the failure is an uncovered line, an upload problem or missing context before changing tests.
2. Inspect uncovered changed lines
Use the PR report or MCP get_uncovered_changed_lines to find paths and ranges. Read the source locally with the surrounding conditions and existing tests. If a line is missing from the report entirely, fix instrumentation or source inclusion first; do not claim it is covered.
When no relevant changed lines are reported, the current calculator returns 100%. Check that this reflects a genuinely non-executable change rather than an empty or mismatched report.
3. Test the behavior, not the percentage
For a newly added error path, assert the error and any effects that must not occur. For a boundary, exercise both sides. Reuse the project’s test helpers and avoid introducing delays or brittle assertions merely to turn the check green.
- Run the focused test while iterating.
- Run the repository’s required suite before publishing.
- Keep source exclusions unchanged unless there is a documented reason independent of the failed check.
4. Re-upload and verify the new head
Run the coverage workflow and wait for processing. Confirm that the head SHA matches your update, the patch check passes and no unexpected project regression appeared. A neutral project check means a baseline is unavailable, not that no regression exists.
If the result is stale, inspect CI artifact generation and processing before rerunning blindly. For an ambiguous multi-format result, select the intended report format.