简体   繁体   English

SonarQube + Jacoco覆盖率差异

[英]SonarQube + Jacoco Coverage Discrepancies

I have been using Jacoco to analyze the Code-Coverage of my team's maven project for almost 3 months now. 我已经使用Jacoco来分析我团队的Maven项目的代码覆盖率近三个月了。 It has been analyzing and increasing properly as we add more and more tests and everything has been working well. 随着我们添加越来越多的测试,并且一切运行良好,它一直在适当地进行分析和增加。

In the last few days we have begun trying to set up a SonarQube analysis of the project. 在过去的几天中,我们已经开始尝试对该项目进行SonarQube分析。 The issue we are running into is that the coverage shown in SonarQube is drastically different from what Jacoco is displaying for us. 我们遇到的问题是,SonarQube中显示的覆盖范围与Jacoco为我们显示的覆盖范围完全不同。

I have looked into this already, and read about some of the solutions online, the problem that seemed most similar to what we were running into can be found at the URL here . 我已经研究过此问题,并在线阅读了一些解决方案,可以在此处的URL上找到与我们所遇到的问题最相似的问题。 But this did not fix the problems we had. 但这不能解决我们遇到的问题。

In our pom.xml file we are working on, I have added in the properties folder these lines: 在我们正在处理的pom.xml文件中,我在properties文件夹中添加了以下几行:

<sonar.coverage.jacoco.xmlReportPaths>./codeCoverage/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.language>java</sonar.language>
<sonar.java.source>8</sonar.java.source>
<sonar.java.libraries>target</sonar.java.libraries>

which are what I have found online telling us how to configure the SonarProperties. 这些是我在网上找到的,告诉我们如何配置SonarProperties。

I am not getting any errors, but the code coverage is different. 我没有收到任何错误,但是代码覆盖率有所不同。

For example in the Jacoco.html file, we have a branch coverage of 9.44% but in SonarQube the conditional coverage is 10.00% . 例如,在Jacoco.html文件中,我们的分支覆盖率为9.44%但在SonarQube中,条件覆盖率为10.00%

The same issues happen with the line coverage which is in Jacoco.html 13.76% as opposed to 11.1% in SonarQube. Jacoco.html中的线路覆盖率为13.76% ,而SonarQube中的11.1%发生了相同的问题。

I was able figure out what was wrong with the setup that we were using, by looking through our SonarQube analysis deeper and comparing package by package what was being analyzed. 通过更深入地浏览SonarQube分析并逐包比较所分析的内容,我能够找出所使用的设置的问题。

SonarQube was analyzing the whole repository, and the default report for coverage that was displayed was reflecting using not only the jacoco.xml but also looking at some code from other types. SonarQube正在分析整个存储库,显示的默认覆盖率报告不仅反映了使用jacoco.xml而且还查看了其他类型的代码。

To see the accurate code coverage, I had to change where we were looking in SonarQube's analysis, to the directory which housed the Java code exclusively thus aligning the coverage percentages between the two services. 为了查看准确的代码覆盖率,我必须将SonarQube分析中的查找位置更改为专门包含Java代码的目录,从而在两个服务之间调整覆盖率。

暂无
暂无

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

相关问题 Sonarqube测试覆盖率过滤器(Jacoco) - Sonarqube test-coverage filter (jacoco) 使用 Gradle 的 Sonarqube 8 的 Jacoco 代码覆盖率 - Jacoco code coverage for Sonarqube 8 using Gradle SonarQube 显示 0% 代码覆盖率,但 JaCoCo 报告是正确的 - SonarQube showing 0% code coverage but JaCoCo reports are correct SonarQube不接受外部生成的JaCoCo IT报告报告 - SonarQube not accepting externally generated JaCoCo report for IT coverage sonarqube+jacoco+junit 代码覆盖率在 sonarqube 仪表板中显示为 0% - sonarqube+jacoco+junit code coverage showing 0% in sonarqube dashboard 在SonarQube +报告中未显示的相关模块中的汇总覆盖范围或覆盖范围由Jacoco生成 - Aggregated Coverage or Coverage in the dependent modules not shown in SonarQube + Reports are generated by Jacoco SonarQube的覆盖范围缺少Jacoco报告涵盖的某些行 - SonarQube coverage missing some lines covered by Jacoco report 使用 JaCoCo 插件配置分析 Maven 插件后,SonarQube 服务器上缺少 JaCoCo 代码覆盖率报告 - Missing JaCoCo code coverage report on SonarQube server after analyzing Maven plugin with JaCoCo plugin configuration SonarQube + Maven + JaCoCo + GitLab CI: Sonar started to show 0% code coverage after upgrading to SonarQube 7.9.2 - SonarQube + Maven + JaCoCo + GitLab CI: Sonar started to show 0% code coverage after upgrading to SonarQube 7.9.2 SonarQube不承认一些Lombok注释 - Jacoco的误导性测试覆盖结果 - SonarQube does not recognize some Lombok annotations - misleading test coverage results by Jacoco
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM