How to skip surefire tests but run failsafe tests?
Asked Answered
C

1

11

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.

Cartercarteret answered 12/10, 2017 at 14:42 Comment(0)
W
25

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
Woolsey answered 12/10, 2017 at 15:2 Comment(2)
Thanks. That helps. It even still allows to do -DskipTests to skip all tests. So this is exactly what I needed.Cartercarteret
Really? That's the part I'm struggling with. I can find all sorts of references on how to set up properties to allow skipping failsafe or surefire independently, but I'm trying to retain the option of using -DskipTests, and everything I've tried breaks that.Gpo

© 2022 - 2024 — McMap. All rights reserved.