Do parallel tasks have separate classpath

I just noticed that setting org.gradle.parallel to true also runs tests in parallel.

Does that mean that all tests are run in the same classpath (e.g. static variables are shared) or are they isolated?


I think there are a couple things here. Parallel executing tests, that is, two tests simultaneously executing do not share a static context because they are executed in completely different JVMs. So to be more specific, parallel test execution is not implemented via threads in a single JVM, but rather, by launching separate JVM workers which are completely isolated from one another.

That said, a single test JVM, by default, will be used to execute multiple tests, serially. So if one test modified a static variable, that modification could subsequently be visible to the next test to run in that JVM.

1 Like