Using the Maven surefire plugin to include tests

Viewed 17158

I am using Maven to build my project. I currently split testing into different hierarchies:

  • Unit tests -> src/test/java/**/*Test.java
  • Integration tests -> src/test-integration/java/**/*Test.java
  • External tests -> src/test-external/java/**/*Test.java

Here is my maven-surefire-plugin section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven-surefire-plugin.version}</version>
    <configuration>
        <includes>
            <include>src/test/java/**/*Test.java</include>
        </includes>
    </configuration>
</plugin>

The <include> directive above does not work. No tests are executed when I run: mvn clean test

I tried **/*Test.java and it runs all the tests -- unit, integration, and external. However, for the default test suite, I only want to run the unit tests.

How can I make this work in Maven?

Ref:

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
3 Answers
Related