Jacoco eclipse插件和SonarQube中的代码覆盖率百分比值不同 [英] Code coverage percentage values in Jacoco eclipse plug-in and SonarQube are different

查看:243
本文介绍了Jacoco eclipse插件和SonarQube中的代码覆盖率百分比值不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java项目。根据Jacoco eclipse插件(EclEmma Java代码覆盖率2.3.1.201405111647),该项目的代码覆盖率为22.3%。我生成.exec报告并将其提供给SonarQube,并使用声纳运行器进行分析。结果,SonarQube网络界面上显示的代码覆盖率为20.2%。软件包级别的coverage值也不同于Jacoco的eclipse插件显示的值。那怎么可能? SonarQube是否不从Jacoco生成的.exec报告中获取值?

I have a Java project. The code coverage of that project according to Jacoco eclipse plug-in (EclEmma Java Code Coverage 2.3.1.201405111647) is 22.3%. I generate the .exec report and feed it to SonarQube and run an analysis with sonar runner. The code coverage shown on SonarQube's web interface as a result is 20.2%. The coverage values at package level are also different to what shown by Jacoco's eclipse plug-in. How is that possible? Isn't SonarQube taking values from the .exec report generated by Jacoco?

推荐答案

Jacoco是基于字节码分析的。 exec文件与类文件结合在一起以获取最终的代码覆盖率值。在我的案例中,问题在于,Eclipse的Java编译器生成的字节码(用于Jacoco eclipse插件)和Javac的生成的字节码(在声纳运行程序分析期间)不同。因此,两个工具生成的代码覆盖率值是不同的。

Jacoco is based on bytecode analysis. The exec file is combined with the class files to get the final code coverage values. The problem in my case was that the bytecode generated by Eclipse compiler for Java (for Jacoco eclipse plug-in) and that produced by Javac (during analysis on sonar runner) were different. Hence, the code coverage values generated by both tools were different.

这篇关于Jacoco eclipse插件和SonarQube中的代码覆盖率百分比值不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆