Run JUnit * test methods in isolation

Is maven-surefire-plugin able to run all JUnit method tags in isolation? Ie, can it fork the JVM for each test method, and not for each test class?

Deprecated Option

<forkMode>pertest</forkMode>

and current

<forkCount>1</forkCount>
<reuseForks>false</reuseForks>

it seems only fork for each test class.

PS: Test methods should be independent, and therefore no one should run each of them on the new JVM (and not to say that it would be very expensive). But I was wondering if there is such an option or not.

+4
source share
1 answer

The Maven Surefire plugin supports this configuration:

<parallel>methods</parallel>

JUnit >= 4.7

:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20</version>
    <configuration>
      <parallel>methods</parallel>
      <threadCount>10</threadCount>
    </configuration>
  </plugin>

.

1 :

JVM, JVM

reuseForks=true forkCount > 1 . , parallel=methods forkCount, threadCount .

, , surefire .

FWIW, JVM , , . , , JVM (, ), ? , , , ?

0

Source: https://habr.com/ru/post/1684781/


All Articles