We are using a custom classloader in our application which will do some bytecode enhancement on loaded classes. I was wondering how can I specify JUnit to use that class loader to load my test cases, which in turn load the testing target classes referenced in the test cases
Asked
Active
Viewed 732 times
1
-
I imagine the only way to do that would be to create your own custom JUnit `Runner`, which uses the custom classloader. Existing custom runners do that for their own specific custom classloaders (eg, the Robolectric and PowerMock runners). – Rogério Aug 27 '15 at 21:44
-
I tried with PowerMock's `org.powermock.classloading.ClassLoaderExecutor` with a customized Rule, however it was bit crappy and I got JVM issues like http://bugs.java.com/view_bug.do?bug_id=6907806. – Gelin Luo Aug 29 '15 at 02:40
-
Can you not set the default class-loader as per http://stackoverflow.com/questions/3801714/how-to-set-my-custom-class-loader-to-be-the-default? – gar Aug 31 '15 at 17:58