Sonarqube 上未显示单元测试覆盖率 - 运行 通过 Jenkins Sonar 插件 - 测试成功正确显示

Unit Test Coverage not displaying on Sonarqube - Running through Jenkins Sonar plugin - Test Success displays correctly

我目前正在使用 jenkins 为我的项目构建不同模块的列表。我使用 Maven 触发构建。我在服务器上安装了 sonarqube 并正确设置了它,这样当一个模块构建时它会显示在 sonarqube 上并包括所有基本细节,如代码行、技术债务等。所有模块都有 Junit 测试 运行 反对他们,sonarqube 通过说单元测试成功是 100% 来显示这一点,它还说了该模块中 运行 的测试数量。但是我无法让单元测试覆盖率字段显示任何内容,并且所有模块都是空白的。

这是我的 pom.xml

的努力(一个模块)
customer.sonar.projectBaseDir=.
customer.sonar.sources=D:/TFS/WorkSpace/DEV_2_HYBRID/APP_FO/application/customer/src/main/java
customer.sonar.Hybrid=Customer
customer.sonar.tests=D:/TFS/WorkSpace/DEV_2_HYBRID/APP_FO/application/customer/target/surefire-reports
customer.sonar.junit.reportsPath=D:/TFS/WorkSpace/DEV_2_HYBRID/APP_FO/application/customer/target/surefire-reports

我使用的软件版本如下: 声纳库 v.5.0, Jenkins Sonarqube 插件 v.2.1, Maven v3.2.5

正如我在开头所说的那样,单元测试成功率确实显示成功,所以我相信只需要一个小的改变就可以让单元测试覆盖率领域发挥作用。

任何帮助将不胜感激!

您需要执行您选择的覆盖引擎并通过适当的 属性 向 SonarQube 提供报告。

如果您使用的是 JaCoCo,报告导入器嵌入在 java 插件中,对于其他覆盖率引擎(clover、cobertura...),您必须安装专用插件。

有关详细信息,请参阅 dedicated page of documentation