Is there a way to tell surefire to skip tests in a certain package?

Eric Winter picture Eric Winter · Dec 8, 2010 · Viewed 22.3k times · Source

Something like the following.

I would like a way to skip my dao tests in surefire. Trying to avoid overhead of defining Suites.

With CI I'd like to have one nightly that runs all tests and another 5 minute poll of SCM that runs only 'fast' tests.

mvn -DskipPattern=**.dao.** test

Answer

yegor256 picture yegor256 · Dec 17, 2010

Let me extend Sean's answer. This is what you set in pom.xml:

<properties>
  <exclude.tests>nothing-to-exclude</exclude.tests>
</properties>
<profiles>
  <profile>
    <id>fast</id>
    <properties>
      <exclude.tests>**/*Dao*.java</exclude.tests>
    </properties>
  </profile>
</profiles>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <excludes>
     <exclude>${exclude.tests}</exclude>
    </excludes>
  </configuration>
</plugin>

Then in CI you start them like this:

mvn -Pfast test

That's it.