Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice integrating Spock with Jenkins, Sonar [closed]

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?

like image 541
Olimpiu POP Avatar asked May 08 '13 11:05

Olimpiu POP


2 Answers

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.

like image 139
Peter Niederwieser Avatar answered Sep 28 '22 04:09

Peter Niederwieser


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.

like image 42
Aaron McDowell Avatar answered Sep 28 '22 04:09

Aaron McDowell