zjffdu
zjffdu

Reputation: 28784

How to skip integration test in maven

I am using apache maven, "-DskipTests" can only skip unit test, but for integration test, how can I skip it ? Does anyone know that ? Thanks

Upvotes: 31

Views: 32950

Answers (3)

neves
neves

Reputation: 39173

It depends on which plugin you are using to execute your integration tests. I presume that you are talking about the integration test phase of maven lifecycle. As @wemu answered, this phase usually is run with the fail safe plugin, but you can use other plugins attached to this phase, like the exec plugin.

Each plugin will (probably) have its own way to skip the tests. You can attach the exec plugin to the integration test phase this way:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>

            <executions>
                <execution>
                    <id>your execution id</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>

You would skip this plugin with the parameter skip in the command lin

mvn integration-test -Dexec.skip

Note that this would skip all your exec plugin executions even if they are in other phases.

Upvotes: 3

Ikbel
Ikbel

Reputation: 2203

To skip running the tests for a particular project, set the skipITs property to true.

<project>
    [...]
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.0.0-M6</version>
                <configuration>
                    <skipITs>true</skipITs>
                </configuration>
            </plugin>
        </plugins>
    </build>
    [...]
</project>

You can also skip the tests via the command line by executing the following command:

mvn install -DskipTests

Since skipTests is also supported by the Surefire Plugin, this will have the effect of not running any tests. If, instead, you want to skip only the integration tests being run by the Failsafe Plugin, you would use the skipITs property instead:

mvn install -DskipITs

If you absolutely must, you can also use the maven.test.skip property to skip compiling the tests. maven.test.skip is honored by Surefire, Failsafe and the Compiler Plugin.

mvn install -Dmaven.test.skip=true

Upvotes: 12

wemu
wemu

Reputation: 8160

Integration Tests are usually executed using the failsafe-plugin.

Depending on the version you are using there are two options: skipTests and skipITs. See examples on the plugin site.

Upvotes: 25

Related Questions