Problem setting I want to investigate some problems we have regarding when objects used in tests are finalized. Therefor I would like to know in greater detail how surefire runs JUnit tests.
It seems that some of these still exist while other tests are run, probably because of
- garbage collection
- surefires timeout for forked JVMs. As this can happen basically at any point in time /at random, I want to understand the interaction between Surefire and JUnit 4.11.
My Question
What is the execution order/path to executing a test method when I invoke mvn test
?
How are tests run with forkCount={0,1}?
How does surefire create a fork of the JVM and where in surefire's source code does this happen?
When is the fork killed and does it run finalizers?
The surefire version used is 2.16.
I found these classes and followed a lot more, but I got sort of lost in the haywire: ForkStarter It seems that surefire manages communication via ForkClient, however I cannot find a the point where a new JVM process is started/ended and the surefire page does not give me a precise clue either.
Also I found this document, giving some pointers for classes to start: https://github.com/apache/maven-surefire/blob/8881fabb9625522a4790ef8c96179233a51e7385/maven-surefire-plugin/src/site/apt/developing.apt.vm