As of version 2.7 of surefire, there is a proposed public api available for external providers to use surefire features.
The key features of surefire are forking, reporting and directory/classpath scanning. The remaining features are implemented in the providers.
Please note that this API is still subject to change until otherwise declared, even in minor revisions. This would mostly happen to facilitate needs in new providers.
There are three things any provider must fulfill:
There are 4 well-known providers within surefire that are also implemented this way, so examples can be found by looking at the surefire source code itself. surefire-junit47 is the showcase implementation.
The javadoc on the intefaces mentioned in this article should otherwise be sufficient to write a provider. Providers are added as dependencies to the surefire/failsafe plugins.
Prior to 2.11, the provider would do
TestsToRun scanned = directoryScanner.locateTestClasses( testClassLoader, scannerFilter );
and the classes would arrive in sorted order. In 2.11, an additional step must be implemented by the provider;
TestsToRun scanned = directoryScanner.locateTestClasses( testClassLoader, scannerFilter ); return providerParameters.getRunOrderCalculator().orderTestClasses( scanned );
Prior to this version, the provider would do
directoryScanner = booterParameters.getDirectoryScanner(); final TestsToRun scanResult = directoryScanner.locateTestClasses( testClassLoader, testChecker );
from this version ProviderParameters#getDirectoryScanner has been deprecated, and *will* be removed for the next major version.
scanResult = booterParameters.getScanResult(); final TestsToRun testsToRun = scanResult.applyFilter(testChecker, testClassLoader );