我有所有这些工具报告与 JaCoCo 相同的覆盖率:69% 的线路覆盖率和 23% 的分支覆盖率.
I have all those tools reporting the same coverage with JaCoCo: 69% line coverage and 23% branch coverage.
注意:截图已经拍摄了好几天,所以它们的值略有不同,但差异是 <1%
詹金斯:
马文:
日食:
然而,Sonar 报告不同的值:
However Sonar reports different values:
Maven项目结构如下:
Maven project is structured as follows:
您可以看到 main 和 java 模块报告的覆盖率相同,而 js 模块没有覆盖率.
You can see the same coverage reported on main and java modules, and no coverage for the js one.
我正在使用最新版本的 jacoco
、jacoco-maven-plugin
和 Sonar 的 Java 插件
.
I'm using the latest versions of jacoco
, jacoco-maven-plugin
and Sonar's Java Plugin
.
以下是来自 mvn sonar:sonar
的相关构建日志片段——一切似乎都井然有序:
Here are the relevant build log fragments from mvn sonar:sonar
-- all seem to be in order:
$ egrep -i 'jacoco|[warn]' consoleText
[WARN] [04:34:29.569] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[WARN] [04:34:29.576] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[WARN] [04:34:29.593] 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
[INFO] [04:34:32.704] JaCoCoItSensor: JaCoCo IT report not found: /home/acme/workspace/example-Sonar-DSL/modules/example-main/target/jacoco-it.exec
[WARN] [04:34:32.952] Bytecode of dependencies was not provided for analysis of test files, you might end up with less precise results. Bytecode can be provided using sonar.java.test.libraries property
[WARN] [04:34:50.101] Cobertura report not found at /home/acme/workspace/example-Sonar-DSL/modules/example-main/target/site/cobertura/coverage.xml
[INFO] [04:35:03.391] Sensor JaCoCoSensor
[INFO] [04:35:03.406] Analysing /home/acme/workspace/example-Sonar-DSL/modules/example-main/target/jacoco.exec
[INFO] [04:35:03.712] Sensor JaCoCoSensor (done) | time=321ms
[INFO] [04:35:03.712] Sensor JaCoCoOverallSensor
[INFO] [04:35:03.714] Analysing /home/acme/workspace/example-Sonar-DSL/modules/example-main/target/jacoco.exec
[INFO] [04:35:03.762] Analysing /home/acme/workspace/example-Sonar-DSL/modules/example-main/target/sonar/jacoco-overall.exec
[INFO] [04:35:03.906] Sensor JaCoCoOverallSensor (done) | time=194ms
[INFO] [04:35:11.013] JaCoCoSensor: JaCoCo report not found : /home/acme/workspace/example-Sonar-DSL/modules/frontend/target/jacoco.exec
[INFO] [04:35:11.013] JaCoCoItSensor: JaCoCo IT report not found: /home/acme/workspace/example-Sonar-DSL/modules/frontend/target/jacoco-it.exec
[INFO] [04:35:11.179] JaCoCoSensor: JaCoCo report not found : /home/acme/workspace/example-Sonar-DSL/target/jacoco.exec
[INFO] [04:35:11.179] JaCoCoItSensor: JaCoCo IT report not found: /home/acme/workspace/example-Sonar-DSL/target/jacoco-it.exec
这是 Sonar 的 Java 插件中的错误吗?我认为当不同人配置的其他 3 个工具始终显示不同的值时,声纳报告的指标不太可能是正确的.
Is this a bug in Sonar's Java Plugin? I think it's highly unlikely that metric reported by sonar is correct when 3 other tools configured by different people consistently show different values.
似乎覆盖率指标已自行修复.它现在报告正确的值——顺便说一句,我们在同一天将 JDK 升级到了最新的补丁版本 (8u92).
It seems like the coverage metric has fixed itself. It now reports correct values -- incidentally we've upgraded JDK to latest patch version (8u92) the same day.
这表明 JaCoCo 传感器根据 JRE 工作不正常,但需要更多调查.
This suggests the JaCoCo sensor works wrong depending on JRE, but needs more investigation.
这篇关于Sonar 报告的线路和分支覆盖率与 Idea、Eclipse、Maven 和 Jenkins 不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!