Refer to the links: GitHub talk on how to separate integration tests and unit tests
As a result, I tried this -
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <includes> <include>**/*Tests.java</include> <include>**/*Test.java</include> </includes> <excludes> <exclude>**/Abstract*.java</exclude> <exclude>**/IT*.java</exclude> <exclude>**/*IT.java</exclude> <exclude>**/*ITCase.java</exclude> <exclude>**/*IntegrationTest.java</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> <configuration> <includes> <include>**/IT*.java</include> <include>**/*IT.java</include> <include>**/*ITCase.java</include> <include>**/*IntegrationTest.java</include> </includes> </configuration> </execution> </executions> </plugin>
It works to some extent. Meaning, surefire does not run integration tests, and Failsafe does not run unit tests.
But, when I run mvn verify or mvn integration-test , the sure-fire plugin is also used.
Desired result: when starting mvn integration-test Unit test should not be performed.
Below are three images for mvn verify
Integration Testing:


Unit tests:

The image below is shown when I ran mvn test

source share