Maven failsafe plugin works fine with the normal JUnit test cases. But what if you wanted to use the Spock framework for your integration tests? This post will focus on the configuring Spock tests written in Groovy because the maven build configuration is tricky when it comes to Groovy. Initially, I used a “.groovy” file extension in the maven failsafe plugin configuration Include entry but the Spock tests did not run at all in my experience. After trying out several things the only way I found a solution to the problem was to add another Include configuration entry with a “.java” file extension for the same Spock Groovy class and it worked. Here’s the relevant part of the maven POM build configuration shown below.
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.19.1</version> <configuration> <includes> <include>**/*Spec.groovy</include> <include>**/*Spec.java</include> </includes> </configuration> … </build>