-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected Coverage Changes #5438
Comments
This was referenced Aug 22, 2023
halibobo1205
added
Improvement
status: on-going
long-term
topic: Code coverage
and removed
type:bug
labels
Feb 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is code coverage?
Code coverage is a measurement used to express which lines of code were executed by a test suite. We use three primary terms to describe each line executed.
Coverage is the ratio of hits / (sum of hit + partial + miss). A code base that has 5 lines executed by tests out of 12 total lines will receive a coverage ratio of 41% (rounding down).
Phrased simply, code coverage provides a visual measurement of what source code is being executed by a test suite. This information indicates to the software developer where they should write new tests in an effort to achieve higher coverage.
Testing source code helps to prevent bugs and syntax errors by executing each line with a known variable and cross-checking it with an expected output.
Percentages on the commit page
These percentages are near identical to what's on a PR, but the comparison for change is a little different. In a pull request you compare a head to a base, but in a commit, the change is determined by comparing to the previous commit on your branch. These percentages are also specific to the commit itself, not the wider PR/MR that the commit is a part and allow you to see a more granular view of how your coverage is changing based on the work done in that single commit.
Introduction
There are many reasons why coverage may change in unexpected ways. Codecov analyzes the pull/commit diff, detecting coverage changes on both lines of code that changed and lines that were not changed.
Indirect coverage changes are differences of coverage to lines of code that are not adjusted in the pull/commit diff. This can occur for a number of reasons. In the UI we call these changes "indirect changes" - on the pull request page you will see an "indirect changes" tab and navigating there will bring you a list of all of the files impacted by indirect changes. More often than not an unexpected coverage change is an indirect change.
Reasons for unexpected changes
There are a number of reasons that cause line coverage to change unexpectedly. These can be due to:
If you want to know more, please refer to https://docs.codecov.com/docs/about-code-coverage
Expected behaviour
Less unexpected coverage changes as possible, CI works in normal.
Actual behaviour
CI often fails due to unexpected coverage changes.
The text was updated successfully, but these errors were encountered: