I need to setup somethings in the environment and inject some environment variables to the JUnit test class before they go on. And I just need to do it once per test processor. I have not seen any nice way in the gradle api to do so. What would you recommend?
I have been reading the source code of Gradle, and I do not see any way to get the Worker instance, it seems to be quite protected.
I think, ForkingTestClassProcessor should give an option to customize the builder, pretty much as it does for the JUnitFramework with “buildConfigAction”, but depending on the testClass. Why not to pass the testClass to the forkProcess() function?
You’re at internals at that level, so the API is not designed for extensibility.
The Test task type exposes methods to set env vars for forked processes (via implementing ProcessForkOptions).
How is what you need to do different to this?
I do not think that what I am trying to do is odd or rare. I just want to prepare some environment right before a testclass. As simple as that. I think the Gradle API is very poor here. Check my other questions: