How to get notified as soon as a new test processor is created by gradle?


(lqb) #1

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?


(lqb) #2

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?


(Luke Daley) #3

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).

https://www.gradle.org/docs/current/javadoc/org/gradle/api/tasks/testing/Test.html

How is what you need to do different to this?


(lqb) #4

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:

http://forums.gradle.org/gradle/topics/anyway-to-make-the-beforesuite-to-block-the-start-of-the-test-suite-i-need-to-do-some-configuration-before