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

A new JVM is forked even for tests not matching the "groups" tag when "reuseForks" is false

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.18.1
    • Backlog
    • None
    • None

    Description

      When the "groups" tag is used with "resuseForks" as false, a new fork is created for every test, not just the one in the group tag. The tests which don't match the group aren't ran, but a fork is still created and destroyed for every test, which is very inefficient.

      Example:

      <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
              <skip>true</skip>
          </configuration>
          <executions>
              <execution>
                  <id>default-tests</id>
                  <phase>test</phase>
                  <goals>
                      <goal>test</goal>
                  </goals>
                  <configuration>
                      <skip>false</skip>
                      <excludedGroups>IsolatedTests</excludedGroups>
                  </configuration>
              </execution>
              <execution>
                  <id>isolatedTests</id>
                  <phase>test</phase>
                  <goals>
                      <goal>test</goal>
                  </goals>
                  <configuration>
                      <skip>false</skip>
                      <groups>IsolatedTests</groups>
                      <forkCount>1</forkCount>
                      <reuseForks>false</reuseForks>
                  </configuration>
              </execution>
          </executions>
      </plugin>
      

      The forking can be seen when running maven in debug mode: mvn test -X and searching for the text "Forking command line"

      Attachments

        Activity

          People

            Unassigned Unassigned
            MComerford Michael Comerford
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: