Search results
Configure Surefire and Failsafe Maven Plugins for Unit and Integration Testing
pom.xml
</properties>
<!-- Maven Plugins -->
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
<maven-failsafe-plugin.version>3.5.4</maven-failsafe-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- Unit tests only, thread-safe, parallel execution -->
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
<testFailureIgnore>false</testFailureIgnore>
<parallel>classes</parallel>
<threadCount>4</threadCount> <!-- CPUs/Cores/Threads-->
<perCoreThreadCount>true</perCoreThreadCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<!-- Integration tests only, non-thread-safe, sequential execution -->
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
<testFailureIgnore>false</testFailureIgnore>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<reportsDirectory>${project.build.directory}/failsafe-reports</reportsDirectory>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Usage
- Unit tests only:
mvn clean package
- Unit and Integration tests:
mvn clean verify
