Best practices for integrating Spock with Jenkins, Sonar

We decided to give Spock a try as a testing base for our Java-based EE application. We currently have a CI infrastructure deployed based on jenkins + maven + jacoco.

Question: The question is, what is the best way to integrate spock with all this? Any recommendations, recommendations?

+7
source share
2 answers

Given your toolchain, the only thing different from Java / JUnit is to compile Groovy (test) into Maven (see spock-example ). Other than that, you don’t need to do anything special, since Spock is just a custom JUnit runner that activates automatically. You will receive the same reports, etc. You can even have Spock and JUnit tests in the same source directory and run them together.

+4
source

In fact, you may have problems integrating with Sonar. The Sonar Surefire Sensor will successfully find your reliable reports; however, the sensor attempts to link the test source for publication in Sonar. When he does this, he assumes the .java file extension. Thus, you will see the output in your assembly, which looks like this:

[INFO] [13: 00: 34.734] Sensor SurefireSensor ...
[INFO] [13: 00: 34.735] parsing / home / amcdowel / accurev / projectFoo / target / surefire-reports
[WARN] [13: 00: 34.747] Resource not found: com.abc.monitor.app.model.MonitorTest

The code coverage generated by your Spock tests will be successfully reported in your Sonar dashboard, but the number of unit tests and the number of errors / errors will not be included.

+2
source

All Articles