0

I have a simple Groovy test class using JUnit

class GroovyJunitTest {
  @Test
  void test() {
    println this.class.getClassLoader().toString()
  }
}

This prints out

sun.misc.Launcher$AppClassLoader@4e25154f

which means that Java classloader is used.

I run the test with both Intellij IDE and using gradle test. The same result is in both cases.

Is there a way to configure JUnit to use Groovy classloader?

Marko Vranjkovic
  • 6,481
  • 7
  • 49
  • 68

1 Answers1

0

Once I had the same problem and I used https://github.com/bitstrings/junit-clptr to load my custom classloader.

Note: this is no longer supported by the crator however for me it did work out. Anyway if it's to important to trust an outside source you can take it as an inspiration and define your own annotation that will let you choose your custom classloader

rakwaht
  • 3,666
  • 3
  • 28
  • 45