简体   繁体   English

Clover和Jacoco给出不同的代码覆盖率结果

[英]Clover and Jacoco give different code coverage results

I just ran a code coverage analysis on my project with Clover and the result is about 60%. 我刚刚在Clover上对我的项目进行了代码覆盖率分析,结果大约是60%。 I ran the analysis on the same project with Jacoco and the result is about 52%. 我与Jacoco在同一个项目上进行了分析,结果约为52%。 Is the 8% difference normal? 8%的差异正常吗? I've been running code coverage analysis with these tools in the past too and the difference is never this huge. 过去我也一直使用这些工具进行代码覆盖率分析,两者之间的区别从来没有这么大。

Please note that Clover and JaCoCo are using different code coverage metrics: 请注意,Clover和JaCoCo使用不同的代码覆盖率指标:

  • Clover has method, statement and branch coverage (plus the total coverage metric which is a sum of all three) Clover具有方法,语句和分支覆盖率(加上总覆盖率度量标准,这是所有三个度量值的总和)
  • JaCoCo has method, code block, line, branch and instruction coverage JaCoCo具有方法,代码块,行,分支和指令范围

So you cannot simply put the equality sign between results produced by these two tools. 因此,您不能简单地在这两个工具产生的结果之间放置等号。 I suggest checking reports side-by-side to find where is the highest difference and next to have a look at code constructs used there, resulting in such difference. 我建议并排检查报告以找出差异最大的地方,然后再查看那里使用的代码构造,从而得出差异。

Oh. 哦。 By the way. 顺便说说。 Keep in mind that JaCoCo uses byte code instrumentation, which means that it will also instrument synthetic methods created by javac compiler and which are not visible in the source code. 请记住,JaCoCo使用字节码检测,这意味着它还将检测由javac编译器创建的合成方法,这些合成方法在源代码中不可见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM