Anyway to make the beforeSuite{} to block the start of the test suite? I need to do some configuration before

My code tested by JUnits are writing some configuration in property files. In order to make possible that several of these junit can run parallely, and also in order to isolate the environment of every testclass, I need to do a copy of the configuration folder, and tell to the test class what is the name of its copy.

I wanted to do the copying of the folder in the beforeSuite{descriptor->} method of the test task in gradle, and use the executor id parsed out of the name (, so that the configuration folder would be something like “config-”. Then I can get the Executor ID in my JUnits through the system property “org.gradle.test.worker”.

The problem is that the beforeSuite{} gets called asynchronously. I mean, it gets called by Gradle, but it does not block the execution of the test class, and therefore the test class does not find the config folder (since it is not yet created).

All of these sounds to me not completely nice, but I can’t think of any other solution. I know that, ideally, JUnits should not touch resources files, but legacy code is what it is.

Any idea?

I have ended up doing a Java Agent that overrides the “get configuration folder” function, to return the specific one for that test class, or creates it if it does not exist. Still, this is not a nice solution, and I think the Gradle API here is lacking of something to interact a bit deeper with the test flow.