Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-571

Using jUnit 4, fork == always, TestSet triggers static initiailization for all test classes in each forked process.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.3
    • 2.5
    • Junit 4.x support
    • 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.

      Attachments

        Activity

          People

            jdcasey John Dennis Casey
            jdcasey John Dennis Casey
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: