I have a multi module project having the following structure:
Project: - module1 - module2 - integration-test - parent pom What is the correct way of achieving the following:
- run unit tests from all modules(except integration-test) using
mvn clean install - run integration tests on demand(may be by using maven-failsafe plugin or via a maven profile? )
- fail the build when integration tests fail.
- By Default integration tests should not be run using
mvn clean install - integration-test module has only the integration tests.
I have tried multiple hacks using maven-failsafe plugin and maven-sunfire-plugin(for unit tests) but not able to achieve the above in standard way.
Following is how the relevant portion of integration-test pom looks like:
<dependencies> <!-- dependencies required for this module--> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.12</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/test/java</source> </sources> </configuration> </execution> <execution> <id>add-integration-test-resources</id> <phase>generate-test-resources</phase> <goals> <goal>add-test-resource</goal> </goals> <configuration> <resources> <resource> <filtering>true</filtering> <directory>src/test/resources</directory> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>run-its</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> currently when i run mvn clean install it runs integration tests too. When i run mvn -Prun-its clean verify, it is running unit tests from other modules too. what am i missing?
run-its...