Selecting Providers
Selecting a Provider
Surefire normally automatically selects which test-framework provider to use based on the version of TestNG/JUnit present in your project's classpath. In some cases it may be desirable to manually override such a selection. This can be done by adding the required provider as a dependency to the surefire-plugin.
The following example shows how to force usage of the JUnit 4.7 provider:
<plugins> [...] <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.5.2</version> <dependencies> <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> <version>3.5.2</version> </dependency> </dependencies> </plugin> [...] </plugins>
The providers supplied with Surefire are surefire-junit3
, surefire-junit4
, surefire-junit47
, surefire-junit-platform
and surefire-testng
. Please note that forcing a provider still requires that the test framework is properly set up on your project classpath.
You can also specify multiple providers as dependencies, and they will all be run and produce a common report. This may be especially handy with external providers, since there are few use cases for combining the included providers.