Usage
Best practice is to define the version of the Surefire Plugin that you want to use in either your pom.xml or a parent pom.xml:
<project>
[...]
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.6.0-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
</build>
[...]
</project>
The Surefire Plugin can be invoked by calling the test phase of the build lifecycle.
mvn testUsing Different Testing Providers
Tests in your test source directory can be any combination of the following:
- TestNG (6.14.3 or later)
- JUnit (4.12+ or 5.x)
Since Surefire 3.6.0, all tests run via the JUnit Platform. The appropriate engine is automatically selected based on your dependencies:
junit:junit(4.12+) - runs via Vintage Enginejunit-jupiter-engine- runs via Jupiter Engineorg.testng:testng(6.14.3+) - runs via TestNG JUnit Platform Engine
Since the test framework dependency is required to compile the test classes anyway, no additional configuration is required.
Note that any normal Surefire integration works identically no matter which test framework is in use - so you can still produce a Cobertura report and a Surefire results report on your project web site for your TestNG tests, for example.
There are additional options available if you are running TestNG tests.
See Using TestNG for more information.



