javamavenmaven-surefire-plugintagging

Maven Test Execution by Tags with JUNIT5 and Surefire


I have test and tagged the tests by the @Tag annotation from the org.junit.jupiter.api package.

This is the pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <groups>one</groups>
            </configuration>
        </plugin>
    </plugins>
</build>
@Tag("one")
public class BubblegumApiIT {
   // SOME TEST CODE
}

Now I want to execute just the tests that are tagged by "one". When I configure the JUNIT with Intellj (instead of 'CLASS' I use 'TAGS') it works. However, the equivalent mvn command does not work.

The equivalent maven command would be mvn -Dgroups=one test or?

But I am executing exactly 0 tests then.

Anybody had this issue before?


Solution

  • By default, the Surefire Plugin will automatically include all test classes with the following wildcard patterns:

    Your test class do not follow the default wildcard patterns. Either rename it or specify in the plugin configuration.

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>3.0.0</version>
      <configuration>
        <includes>
          <include>ReservationApiIT.java</include>
        </includes>
      </configuration>
    </plugin>