When I run mvn test
it executes unit tests only but when I run mvn integration-test
it executes both unit test and integration test even after configuring the maven-failsafe-plugin
and excluding the *Test.java
file. Not sure what I am missing here. Also worth mentioning that I have not put in maven-surefire-plugin
in my pom.xml. Not sure if that is creating this problem. Please guide.
pom.xml
<!-- Integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Unit Test Class File:
com.study.jenkins.ut.MyUnitTest.java
Integration Test Class File:
com.study.jenkins.it.PageIT.java
The maven-surefire-plugin
is part of the lifecycle, which is always bound to the test
-phase for Java projects. Calling integration-test
means that all lifecycle-phases up to the integration-test
phase are executed. So the MyUnitTest will always be executed (which is a good thing).
Your includes/excludes have no effect, these are already the defaults for the maven-failsafe-plugin
, see http://maven.apache.org/surefire/maven-failsafe-plugin/integration-test-mojo.html#includes