My Java Maven project separates unit tests from integration tests in the directory structure:
- Unit tests under
src/test/java
; - Integration tests
src/integration-test/java
.
src/integration-test/java
is a non-default test source directory, so I added it manually to the project using build-helper-maven-plugin
, as you can see:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/integration-test/java</source>
</sources>
</configuration>
</execution>
...
</executions>
</plugin>
I also used maven-failsafe-plugin
to include the test integration classes in the test execution flow, as shown below.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
...
</configuration>
</execution>
</executions>
</plugin>
This approach works, but obliges me to use a naming convention in the test classes. Precisely, only the ones ending with "IntegrationTest" will be executed.
I would like to configure the plugin based on a naming convention in the path and not in the file name. Precisely, I intend to allow all classes under src/integration-test/java
regardless the file names. I did not succeed so far and every tutorial in the web only shows the approach I implemented and showed you above.
Does anyone have any suggestion on how to do that?
Thanks
Aucun commentaire:
Enregistrer un commentaire