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

Journal.IO 1.3 released

AboutJust a moment ago (in February 17th) Journal.IO 1.3 has been released. Journal.IO (https://github.com/sbtourist/Journal.IO) is a lightweight, zero-dependency journal storage implementation written in Java. We use it in our project for storing appl...AboutJust a moment ago (in February 17th) Journal.IO 1.3 has been released. Journal.IO (https://github.com/sbtourist/Journal.IO) is a lightweight, zero-dependency journal storage implementation written in Java. We use it in our project for storing appl...