Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.4.3
-
None
Description
It seems that initializing the Runner instance during construction of the JUnitTestSet class causes surefire to trigger static initialization for each test class, in each forked process. If you setup forkMode == always, this means that every test class will have its static initialization triggered N times, once for each class that is executed.
In cases where tests rely on static initialization to set system properties, or something else that's a part of the static environment, forkMode == always should isolate each test class from the others, providing a safe environment in which each test can execute. Since the initialization of these TestSets is eager (rather than lazy), it doesn't matter that only one of the TestSet instances will actually be run; they all execute any static blocks they contain.