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中的代码覆盖百分比值不同
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01