1

I've been working with gcovr to generate coverage data for my whole project.

I am able to generate summary reports like this:

------------------------------------------------------------------------------
                   GCC Code Coverage Report
Directory: ...../src/
------------------------------------------------------------------------------
File                                       Lines    Exec  Cover   Missing
------------------------------------------------------------------------------
src/A/A1/xyz.cpp                            1609       2     0%   97,99,101....
src/A/A2/abcg.cpp                            271       4     1%   .......
src/B/B1/mnop.cpp                             74       2     2%   34,42,56-.....
src/B/B2/wrds.cpp                           1533       6     0%   76,83,85-.....
src/C/C1/abcdefg.cpp                        1079       8     0%   143,150,152.....

with total and everything else too, but this data is at source level. So I tried generating xml files which had the same kind of data in xml format. When I finally generated denser xml file with line level coverage like this one:

<class branch-rate="0.285714285714" complexity="0.0" filename="src/absc/mno/xyz/ahgs.cpp" line-rate="0.231481481481" name="os_clib_hxx">
<methods/>
<lines>
<line branch="false" hits="0" number="200"/>
<line branch="false" hits="0" number="202"/>
<line branch="false" hits="3" number="208"/>
<line branch="false" hits="3" number="210"/>
<line branch="false" hits="63" number="213"/>
<line branch="true" condition-coverage="50% (1/2)" hits="63" number="215">
<conditions>
<condition coverage="50%" number="0" type="jump"/>
</conditions>
</line>
<line branch="false" hits="0" number="218"/>
.........
..........

I still couldn't find anything method level. I know it is possible with gcov to generate method level coverage for one file at a time, but that is not possible in my case as I am working with thousands of files, for which if I try to generate data for each of them by any method it would be problematic.

Vikas Tawniya
  • 1,323
  • 1
  • 13
  • 22

1 Answers1

3

Unfortunately, gcovr is not currently able to report coverage on a per-function basis.

The XML report contains an empty <methods/> section because this section is required by the DTD schema for the Cobertura XML format, but it does not contain useful data. Similarly, other XML fields like complexity just contain dummy data.

amon
  • 57,091
  • 2
  • 89
  • 149