2017-02-24 50 views
1

我一直在使用gcovr爲我的整個項目生成覆蓋率數據。如何使用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可以一次爲一個文件生成方法級別的覆蓋率,但在我的情況下這是不可能的,因爲我正在處理數千個文件,如果我嘗試通過以下方式爲每個文件生成數據任何方法都會有問題。

回答

1

不幸的是,gcovr目前無法報告每個功能的覆蓋範圍。

XML報告包含空的<methods/>部分,因爲Cobertura XML格式的DTD模式需要此部分,但它不包含有用的數據。同樣,其他XML字段(如complexity)僅包含虛擬數據。