Search code examples
javamavensonarqubespock

Integrate Spock's test with Sonar


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 ?

Sonar Dashboard image


Solution

    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 Spock and JUnit tests in Sonar