Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip surefire tests but run failsafe tests?

In my project I have surefire as well as failsafe tests.

If I run with mvn clean install -DskipTests then both kinds of tests are skipped.

If I try to run a single failsafe test using -Dit.test=TestName then first all surefire tests run and then my it test.. but as the surefire tests take a long time this is not good.

I would like to skip the surefire tests in some cases but run the failsafe IT tests.

like image 960
Christian Schneider Avatar asked Jan 23 '26 01:01

Christian Schneider


1 Answers

It's sometimes kind of confusing (annoying?) that, by default, -DskipITs=true will skip Failsafe but -DskipTests=true will skip both Surefire and Failsafe tests.

Anyway, you can change this behaviour by configuring the Surefire plugin to use a different 'skip' parameter. For example:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12.4</version>
    <configuration>
        <skip>${skipSurefire}</skip>
    </configuration>
</plugin>

This will allow you to skip Surefire tests but not Failsafe tests by invoking:

mvn clean verify -DskipSurefire=true
like image 104
glytching Avatar answered Jan 25 '26 22:01

glytching



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!