【问题标题】:Unit Test Coverage not displaying on Sonarqube - Running through Jenkins Sonar plugin - Test Success displays correctlySonarqube 上未显示单元测试覆盖率 - 通过 Jenkins Sonar 插件运行 - 测试成功显示正确
【发布时间】:2015-06-24 08:26:38
【问题描述】:

我目前正在使用 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

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

正如我在开始时所说的,单元测试成功率确实显示成功,所以我相信只需进行很小的更改即可使单元测试覆盖范围发挥作用。

任何帮助将不胜感激!

【问题讨论】:

  • 您使用的是哪个覆盖引擎?您如何生成覆盖率报告?

标签: unit-testing maven junit jenkins sonarqube


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2016-04-19
    • 2018-02-15
    • 2014-07-15
    • 2020-02-25
    • 2015-05-06
    • 2019-07-07
    • 2017-11-18
    • 2014-12-15
    • 2014-02-21
    相关资源
    最近更新 更多