Migration help - Running individual unit tests on a unique JVM


(Stuart Sinclair) #1

Hi all,

I’m running into a problem with migrating an old maven project to gradle. The project has some awful unit tests that are run on unique JVM instances per test, not even per test class. As defined by the surefire plugin:

  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
    <executions>
      <execution>
        <id>default-test</id>
        <phase>test</phase>
        <goals>
          <goal>test</goal>
        </goals>
        <configuration>
          <forkMode>perTest</forkMode>
        </configuration>
      </execution>
    </executions>
    <configuration>
      <forkMode>perTest</forkMode>
    </configuration>
  </plugin>

I’ve seen that Gradle supports forkEvery = 1 to run test classes on unique JVM instances, but I need to go one step further. Manually fixing these tests could take beyond the heat death of the universe, and I’m kinda short on time. :wink:

Any thoughts if it’s possible to run the tests on individual JVM instances? I’m not so bothered about the tests taking longer (for now), I plan on coming back to this.

Thanks!


(Stuart Sinclair) #2

Seems I was mistaken about the perTest forkmode. I understood it as a per test case behaviour, but it seems to be synonymous with surefire’s always, according to stackoverflow and the surefire jira board.

forkEvery = 1 should_do what I’m after.