将 Spock 的测试与声纳集成

2022-01-17 00:00:00 sonarqube java spock maven

我使用 spock 编写测试用例,使用 jenkins 运行和发布我的测试用例.我能够得到报告的代码覆盖率,但声纳向我显示仅 Java 单元测试用例;完全没有常规测试用例

以下 pom.xml 用作参考

解决方案

  1. 在 Sonar 中安装 Groovy 插件.以管理员/管理员身份登录并转到管理/系统/更新中心选项卡
  2. 在pom文件

    <sonar.tests>src/test/groovy,src/test/java</sonar.tests>

如果您这样做,Spock 和 JUnit 测试都会正确显示!见附件截图

I use spock to write test case and jenkins to run and publish my test cases. I was able to get the code coverage reported but sonar shows me only Java Unit test cases; the groovy test cases are totally missing

The following pom.xml is used as reference https://github.com/kkapelon/java-testing-with-spock/blob/master/chapter7/spring-standalone-swing/pom.xml

would anyone please know what I am missing ?

解决方案

  1. Install the Groovy plugin in Sonar. Login as admin/admin and go to the administration/system/update-center tab
  2. Add the following property in the pom file

    <sonar.tests>src/test/groovy,src/test/java</sonar.tests>

If you do this both Spock and JUnit tests are shown correctly! See attached screenshot

相关文章