7

I've set forkCount to zero in my maven-failsafe-plugin configuration so that I can easily use mvnDebug and set breakpoints in my tests while debugging.

This results in the warning:

The parameter forkCount should likely not be 0, not forking a JVM for tests reduce test accuracy, ensure to have a <forkCount> >= 1.

Why is that? What effect on accuracy does not forking have?

TylerH
  • 20,799
  • 66
  • 75
  • 101
tgdavies
  • 10,307
  • 4
  • 35
  • 40

1 Answers1

0

From what I have read, it seems like forkCount=0 would keep the same VM that mvn is running in for the tests. This could potentially cause issues with mvn process and maybe cause potential inaccuracies in tests. forkCount=1 should start 1 new VM (leaving the mvn one alone) to run the tests in. This keeps mvn and the tests separate.

Something I have experienced that can definitely interfere with test accuracy is the reuseForks property. If set to true, static data or static classes could remain in the forked VM which could effect future tests. Tests run faster though. When reuseForks = false, the forked VM is killed and a new one is started. This prevents any static data issues or bad test cleanup (this is not a great solution if its just bad test cleanup/isolation that is the problem). Tests run slower but more accurately.

Main source: https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html

Ironchef
  • 26
  • 4