This exposes an interface(named TestListPreprocessor, which has a method named preprocessTestClasses) that can be implemented by a user and injected into surefire plugin configuration to have it used for preprocessing list of tests to be run. Given the original test list, user's preprocessing algorithm can choose to prune or reorder the list and return it back from TestListPreprocessor#preprocessTestClasses, which is then used as the list of tests to be executed.
The patches attached expose a configuration element named "testPreprocessor" the default value of which is "none". User can choose to set it to a value matching the format "<fully-qualified-class-name>[<group-id>:<artifact-id>:<version>]" and have the class loaded and called with list of tests to be run. The list of tests returned by the call is then considered for execution.
The feature is done in 2 patches. Description follows:
This patch actually adds the feature and unit tests. It adds the interface, an abstraction that encapsulates aforementioned configuration, booter serialization/deserialization, directory-scanner changes etc. The changes have effect in both forked and in-process execution mode.
This patch adds an integration test for preprocessor feature. The integration test uses a 2 module setup, where the first module implements the TestListPreprocessor interface which selects only even indexed test classes from the list passed in. The second module(which depends on first) uses the artifact from first and uses the following configuration:
The test then asserts that only 2(0th and 2nd) of the 4 test classes the second module has are executed.
The patches are created on a git-svn clone using format-patch, please use 'patch -p1 < 0001-Adds...'(while in the trunk directory) to apply the patches on svn repository. If using git-svn, git-am can be directly be invoked.
The patches are done over http://svn.apache.org/repos/asf/maven/surefire/trunk@1091357 (trunk HEAD) so should apply cleanly on any recent enough revision.