My directory structure is like so:
src/integrationTest/java
src/test/java
src/main/java
I a
By default failsafe is configured to only include IT*.java, *IT.java or *ITCase.java. While at the same time, only test sources from src/test/java
are compiled. You need to modify both of these behaviors.
Use build-helper-maven-plugin
to add src/integationTest/java
as test source for maven-compiler-plugin
to pick up automatically. (You've already done this in your last attempt.)
Direct maven-surefire-plugin
to exclude your integration tests (see example below) or to include only non-integration tests (see default includes).
Direct maven-failsafe-plugin
to only include your integration tests instead of default includes.
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<excludes>
<exclude>**/*Stuff.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*Stuff.java</include>
</includes>
</configuration>
</plugin>
In fact using testClassesDirectory
might also work for limiting scope of each test plugin, but you would have to make changes to maven-compiler-plugin
to output classes to different folders, perhaps splitting it's test-compile
execution into two, so maybe it's not worth the effort.
Got working integration tests on Groovy residing in src/test/groovy
with this configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<id>spock-integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<failIfNoTests>true</failIfNoTests>
<testSourceDirectory>${project.basedir}/src/test/groovy</testSourceDirectory>
<includes>
<include>**/*Specification</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Note that pattern in <include>
doesn't contain file extension (**/*Specification.groovy
doesn't work)