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中的代码覆盖百分比值不同
基础教程推荐
- 存储 20 位数字的数据类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
