9

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.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64

1 Answers1

22

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
glytching
  • 44,936
  • 9
  • 114
  • 120
  • Thanks. That helps. It even still allows to do -DskipTests to skip all tests. So this is exactly what I needed. – Christian Schneider Oct 13 '17 at 07:36
  • 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. – Geoffrey Wiseman Feb 16 '19 at 14:35