We decided to give Spock a try as a testing framework for our java based EE application. Currently we have a CI infrastructure deployed based on jenkins + maven + jacoco.
Q: the question is what's the best way to integrated spock with all this? Any recommendations, best practices?
Given your tool chain, the only thing that's different compared to Java/JUnit is to make Groovy (test) compilation work in Maven (see the spock-example project). Other than that, you shouldn't have to do anything special, as Spock is just a custom JUnit runner that's activated automatically. You'll get the same reports etc. You can even have Spock and JUnit tests in the same source directory and run them together.
Actually you may have trouble integrating with Sonar. The Sonar Surefire sensor will successfully find your surefire reports; however, the sensor attempts to link to the test source for publishing to Sonar. When it does this, it assumes a file extension of .java. So you will see output in your build that 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 successfully be reported in your Sonar dashboard, but the number of unit tests and success/error counts will not be included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With