Can you Include other files in code coverage percentages?

Oct 31, 2016 at 7:00 PM
I have been working with OpenCppCoverage for a bit now, trying to compute the code coverage percentage for a particular DLL.

It seems to work by aggregating the results for all the files that are exercised by the code in the DLL. What I want to do is also include all the other files that are in the DLL but are not touched at all.

For example, let's say I have some tests that are exercising 90% of one file in the DLL, and 0% of nine other files. This would be displayed as 90%, but instead I would like to see a 90%(1) + 0(9) / 10 = .9%.

Is this currently possible?

Also, are there any plans to have a method by method breakdown of coverage?
Coordinator
Nov 2, 2016 at 11:04 PM
Hello,

Now the coverage by module is defined as the ratio between the total number of lines covered divides by the total number of lines for the files considered times 100.
If I understand correctly your needs, you would like to compute the average by module with the same weight for big file that for small one?
In your example the expected result shouldn't be 9% ( ((90 * 1) + (0 * 9)) / 10 = 9).

If you want to have a different kind of aggregation you should generate xml export (cobertura) and compute the aggregation you want.
I would like to add in the future a way to let people customize the aggregation by some kind of plugin.

Also, are there any plans to have a method by method breakdown of coverage?

One thing is sure that this is an interesting feature I would like to implement but it requires some time (In C++ not everything is a class or a method).
If you really need this feature now, please see https://opencppcoverage.codeplex.com/discussions/658102 for more information.

I hope this will help,

OpenCppCoverage
Nov 8, 2016 at 2:03 PM
No, that's not what I meant, sorry.

I want to consider files that are not touched.

I want to consider files that are in the DLL / PDB but not touched by the tests. So if I have 100 files in the PDB but only 50 are hit by the test I want to consider those other 50 in calculations.
Coordinator
Nov 22, 2016 at 11:54 AM
Hello,

If I understand correctly this should already be the case.

For example, consider the following 3 files.
// Main.cpp
int main(int argc, char **argv) 
{
    return 0;
}

// Bar.cpp
void Bar() {}

//Foo.cpp
void Foo() {}
If you run code coverage on these files you will have:
  • Main.cpp: 3/3 100%
  • Bar.cpp: 0/1 0%
  • Foo.cpp 0/1 0%.
For the whole module the coverage is 3 / (3 + 1 + 1) = 60%.
File Bar.cpp is not touched by any test but part of the coverage.

I suspect this is not what you want. Can you provide a full example as I did?

I hope this will help,

OpenCppCoverage
Coordinator
Nov 27, 2016 at 2:13 PM
Hello,

You can also found more explanation here.

I hope this will help,

OpenCppCoverage
Marked as answer by OpenCppCoverage on 1/15/2017 at 6:11 AM