我在 Jenkins 上设置了 gcov 代码覆盖工具。
这很好用,但我很难理解输出颜色代码。每条线的“命中”数是正确的,但有些线是绿色的,而另一些是红色的,我不知道为什么。
例子 :
请注意,setYear 方法全是绿色的,并且调用了 13 次(在屏幕截图中可以看到 setDateAAMMJJ 中的 ctor + 12 次)
我在 Jenkins 上设置了 gcov 代码覆盖工具。
这很好用,但我很难理解输出颜色代码。每条线的“命中”数是正确的,但有些线是绿色的,而另一些是红色的,我不知道为什么。
例子 :
请注意,setYear 方法全是绿色的,并且调用了 13 次(在屏幕截图中可以看到 setDateAAMMJJ 中的 ctor + 12 次)
如果您查看cobertura-plugin
github上的源代码,您会看到:
table.source tr.coverPart td.hits, table.source tr.coverNone td.hits {
background-color: #fdd;
font-weight: bold;
}
和
table.source tr.coverPart {
background-color: #ffd;
}
#fdd
是红色,#ffd
是黄色的您应该能够使用浏览器的“开发者工具”或“检查器”功能来查看应用了哪个类。
The yellow on the far left means the source code is covered partly, that means you probably don't have 100% coverage in the functions that are being called.
Another case I can think of (pure speculation at this point) is that some optimization is mangling your statement coverage; check your compilation flags.
If you kept the data (lcov files), you should be able to use genhtml
to generate a report and compare.
Don't know if this applies for you but it seems relevant. In my case it is red because branch cover is not 100%. When generating an xml with gcovr it also adds branch cover data.
It is possible to cover all the lines but not cover all the branches. Im having all kinds of problems with the branch cover.
Some are described in these posts.
为什么 gcc 4.1 + gcov 报告 100% 的分支覆盖率,而更新的(4.4、4.6、4.8)报告“p = new class;”为 50% 线?
仍在寻找解决此类问题的方法..