Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 870
zjffdu Avatar asked Jul 06 '16 17:07

zjffdu


3 Answers

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.

like image 80
wemu Avatar answered Oct 20 '22 23:10

wemu


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
like image 3
Ikbel Avatar answered Oct 20 '22 23:10

Ikbel


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.

like image 2
neves Avatar answered Oct 20 '22 22:10

neves