Running integration tests with surefire in integration-test phase

The Maven Failsafe Plugin is a fork of the Maven Surefire Plugin designed to help when running integration tests. However, sometimes you may want to use Surefire for integration testing. The situation may be even more complicated if have unit tests and integration tests in the same module. The solution isn’t very pretty but it’s still quite short and understandable…

The Maven Failsafe Plugin is a fork of the Maven Surefire Plugin designed to help when running integration tests. However, sometimes you may want to use Surefire for integration testing. The situation may be even more complicated if have unit tests and integration tests in the same module. The solution isn’t very pretty but it’s still quite short and understandable:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <skip>true</skip>
    </configuration>
    <executions>
        <!-- run all tests except integration tests -->
        <execution>
            <id>surefire</id>
            <phase>test</phase>
            <goals>
                <goal>test</goal>
            </goals>
            <configuration>
                <skip>false</skip>
                <excludes>
                    <exclude>pl/touk/cc/dao/mybatis/integration/**</exclude>
                </excludes>
            </configuration>
        </execution>
        <!-- run all integration tests -->
        <execution>
            <id>surefire-it</id>
            <phase>integration-test</phase>
            <goals>
                <goal>test</goal>
            </goals>
            <configuration>
                <skip>false</skip>
                <includes>
                    <include>pl/touk/cc/dao/mybatis/integration/**</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin>
You May Also Like

Apache HISE + Apache Camel

Check out this SlideShare Presentation: Apache HISE + Apache CamelView more presentations from Rafal Rusin.Check out this SlideShare Presentation: Apache HISE + Apache CamelView more presentations from Rafal Rusin.