gpt4 book ai didi

java - Sonar 错误的整体覆盖(jacoco)

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:13:05 25 4
gpt4 key购买 nike

我在多模块 Java8 项目上运行 Jacoco 和 Sonar。我在每个模块中都有单元测试,为了节省资源,我将所有“集成测试”收集到一个“集成测试运行器”中,并在那里运行它们(用测试前后包装它们)。

当测量覆盖率时,UT 为每个模块 target/jacoco-ut.exec 生成 exec 文件,而 IT 生成一个 exec 文件:/target/jacoco-it.exec。

当我运行 sonar 时,我会重复使用这些 exec 文件,为 jacoco-it.exec 提供路径。

我得到一个非常奇怪的图像: enter image description here

总体覆盖率怎么会更低?

最佳答案

我找到了问题和解决方案。

From Sonar website I see this :

By default, when no coverage report is found, the JaCoCo plugin will not set any value for coverage metric. This behaviour can be overriden to force coverage to 0% in case of a lack of report by setting the following property : sonar.jacoco.reportMissing.force.zero=true


这意味着未进行任何测试的模块将跳过 UT 分析。由于我已经从父 pom 设置了 sonar.jacoco.itReportPath 然后 所有 模块都分析了集成测试覆盖率和 总体 覆盖率。

底线:从父 pom 设置属性 sonar.jacoco.reportMissing.force.zero=true 固定数字。

关于java - Sonar 错误的整体覆盖(jacoco),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29018000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com