0

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
Nital
  • 5,784
  • 26
  • 103
  • 195

1 Answers1

1

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

Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
  • I could run just the integration tests using "mvn failsafe:integration-test" – Nital Feb 12 '15 at 21:00
  • 1
    Don't forget to add `failsafe:verify`, because the `integration-test` goal will only run the tests and gather the results, the `verify` goal will actually evaluate the results and check if there are failures. – Robert Scholte Feb 13 '15 at 08:53