Skip to content
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

Add note, incremental coverage is 0 #263

Open
lirui311012 opened this issue Dec 9, 2021 · 3 comments
Open

Add note, incremental coverage is 0 #263

lirui311012 opened this issue Dec 9, 2021 · 3 comments

Comments

@lirui311012
Copy link

After integrating diff-cover, a line of code appears to be commented out, and the incremental code coverage is 0. How to solve this?
I think adding a line of comment code, this line of code will not be compiled, then the denominator of the incremental coverage should be 0, so the coverage should be 100%

@Bachmann1234
Copy link
Owner

Does diff cover report any missing lines? In the scenario you described I would not expect diff cover to report any lines as missing ...

Can you show an example?

@lirui311012
Copy link
Author

for example:
Unmodified code:
src/test.cpp
#include
using namespace std;
int main()
{
int a = 10;
int b= 20;
int c = a + b;
cout << (a + b) << endl;
return 0;
}
Modified code:
src/test.cpp
#include
using namespace std;
int main()
{
int a = 10;
int b= 20;
// int c = a + b;
cout << (a + b) << endl;
return 0;
}
The comparison can be found, int c = a + b; is blocked
but,This line of code should not be calculated into the incremental code, so that is 100% coverage
However, in the actual test, this line of blocked code is calculated as incremental code and is not covered by the google test unit test case

@Bachmann1234
Copy link
Owner

It sounds like the coverage report is returning something incorrect? Diff cover does not compute coverage itself.

It takes coverage computed by another tool and compares it to the diff.

So if the underlying coverage tool is reporting the wrong thing then you need to look at that tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants