By default maven surefile plugin run tests in isolated (forked) environment. You can override this behavior with following configuration:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>never</forkMode>
</configuration>
</plugin>
</plugins>
</build>
If you need to debug your tests you should to use this configuration snippet. Or you could simply run maven build the following way:
$ mvn -Dmaven.surefire.debug tests
This will starts a debugger on the port 5005.
My question is: what benefits have forking strategy and why is chosen as a default strategy for maven build? Isn't nonforking strategy is more straightforward and therefore should be used as default (maven is convention over configuration tool, right)?
forkMode
is now deprecated, reuseForks should be used instead – GerminforkCount=0
is what should be used now to disable new JVMs launching. maven.apache.org/surefire/maven-surefire-plugin/… – Prier