GroovyClassLoader in Junit tests

Per Nyfelt <[email protected]> Fri, 28 Feb 2025 16:29:29 +0000
Newsgroups gmane.comp.lang.groovy.user
Message-ID <[email protected]>
Hi,

Ever so often i find myself wishing that Junit tests in Gradle would use the GradleClassLoader instead of the default system classloader (e.g. to enable use of dynamic (conditional), runtime dependencies without having to run those tests in script blocks)
In Junit 5 it is possible to create a LauncherInterceptor and configure it using
test {
  systemProperty(”junit.platform.launcher.interceptors.enabled “, true)
  // ...
}
Then then LauncherInterceptor needs to be added to /META-INF/services/org.junit.platform.launcher.LauncherDiscoveryListener

As this is a bit involved, I wonder if anyone knows of Gradle Plugin that does that (i.e. runs all Groovy tests using a GroovyClassloader)?

Regards,
Per