Looking for additional help?
See our video tutorial on diagnosing unexpected coverage changes at the bottom of this page.
There are many reasons why coverage may change in unexpected ways.
Coverage changes are coverage to lines of code that are not adjusted in the pull/commit diff. This can occur for a number of reasons.
Codecov will analyze the pull/commit diff, detecting lines of code that changed without being adjusted. A simple example of this is removing tests, which is shown below.
## Unchanged source def string_len(string): return len(string) ## Removed test - def test_my_method(): - assert string_len('jedi') == 4
In the code above, the developer removed a single test which changes the coverage of the method
string_len from being
This change in coverage will be surfaced in the Codecov App through our Changes page.
There are a number of reasons that cause line coverage to change unexpectedly. These can be due to:
- Adding or removing tests.
- Failing to upload coverage reports, or a different number of reports between head and base
- Time-sensitive tests (e.g., one case before 2pm UTC, a different case after 2pm UTC).
- Missing coverage reports or failed builds.
- Dependencies changed resulting in a different execute plan.
- Encrypted variables may prevent some execution paths.
- In the case of changes to a PR, the base or head commits may not have had an uploaded report, or may not be the commit you expect
- Different error handling paths: sometimes exception handlers are tested and some are not, oftentimes the root of "flaky" tests
- Due to long running test builds or dynamic test selection, you are intentionally not running all tests on every commit. If this is the case, please check out our feature Carryforward Flags
Most unexpected changes occur in the raw coverage report before Codecov processes the uploaded coverage file.
How to review the the coverage report for unexpected changes:
- Open the head and base commits for this PR, seen below in the "Source" section surrounded by a green box below.
- On the right hand side of a commit page you will find the raw coverage reports listed in order of upload
- The first piece to investigate is the number of reports themselves. Are they the same between the two commits? If they're different, that's likely the cause of the discrepancy. In the example above, you can see in the highlighted box there's "2 errored, 14 successful" - you want to see an identical result between both commits to rule this out.
- Click the Download button on one or more of your uploads - if you're seeing coverage changes on a specific flag, it might be easiest to focus on the relevant reports to that flag.
- In your downloaded file, ctrl+f on "# path=" to take you past your file list and directly to the beginning of your raw coverage reports.
- Review the raw coverage reports from one commit to the next looking for discrepancy in coverage, if you have a hit on the file from one commit, but not the file from the other commit, that's going to be the source of your coverage change.
- You'll next need to review the specified lines of code with different coverage reports from both commits to determine the root cause.
Codecov stores the raw, unprocessed report data precisely for this issue. Reports are archived for 30 days before removal.
Example repository from video: https://github.com/kensho-technologies/graphql-compiler/pull/806
Updated 21 days ago