【问题标题】:How to get method level coverage with gcovr?如何使用 gcovr 获得方法级别的覆盖率?
【发布时间】:2017-07-15 01:11:02
【问题描述】:

我一直在使用 gcovr 为我的整个项目生成覆盖率数据。

我能够生成这样的摘要报告:

------------------------------------------------------------------------------
                   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.....

包括总数和其他所有数据,但此数据是源级别的。所以我尝试生成具有相同类型数据的 xml 格式的 xml 文件。当我最终生成具有像这样的行级覆盖的更密集的 xml 文件时:

<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"/>
.........
..........

我仍然找不到任何方法级别。 我知道 gcov 可以一次为一个文件生成方法级别覆盖率,但在我的情况下这是不可能的,因为我正在处理数千个文件,如果我尝试通过任何方式为每个文件生成数据方法会有问题。

【问题讨论】:

    标签: code-coverage gcov gcovr


    【解决方案1】:

    很遗憾,gcovr 目前无法按功能报告覆盖率。

    XML 报告包含一个空的 &lt;methods/&gt; 部分,因为该部分是 Cobertura XML 格式的 DTD 模式所必需的,但它不包含有用的数据。同样,complexity 等其他 XML 字段仅包含虚拟数据。

    【讨论】:

      猜你喜欢
      • 2020-02-26
      • 1970-01-01
      • 1970-01-01
      • 2014-10-13
      • 1970-01-01
      • 2016-08-04
      • 2015-02-12
      • 2022-11-11
      • 2012-03-17
      相关资源
      最近更新 更多