Code coverage percentage values in Jacoco eclipse plug-in and SonarQube are different(Jacoco eclipse插件和SonarQube中的代码覆盖百分比值不同)
问题描述
我有一个 Java 项目.根据 Jacoco eclipse 插件(EclEmma Java Code Coverage 2.3.1.201405111647),该项目的代码覆盖率为 22.3%.我生成 .exec 报告并将其提供给 SonarQube 并使用 sonar runner 运行分析.SonarQube 的 Web 界面上显示的代码覆盖率为 20.2%.包级别的覆盖率值也与 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中的代码覆盖百分比值不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Jacoco eclipse插件和SonarQube中的代码覆盖百分比值不同
基础教程推荐
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01