Re: Custom classloader

"Johannes Ernst [email protected] [junit]" <[email protected]> Mon, 18 May 2015 13:55:38 -0700
Newsgroups gmane.comp.java.junit.user
Message-ID <[email protected]>
Thanks, Aaron. I’ve been poking around the code, and found that

1) it isn’t a supported use case
2) it probably wouldn’t be too hard to come up with a junit patch to enable it, assuming the entry point would be the API not main()

but also, given that I’m invoking junit from maven/surefire:

3) it would be much harder to convince maven’s surefire plugin to use a custom classloader and somehow pass it over to junit

So … unless some major work is done by two projects — surefire and junit — I think the answer to my question about whether it can be done is No.

P.S. If anybody is more knowledgeable about this than me (very easy to accomplish, I am not familiar with either code base), please correct me if I’m wrong.

Cheers,


Johannes.

> On May 17, 2015, at 23:59, Aaron VonderHaar [email protected] [junit] <[email protected]> wrote:
> 
> 
> I know the robolectric test runner [1] sets up a custom ClassLoader, but my understanding is that it has to do some weird things to make that work due to the fact that the test class has already been loaded by the time the TestRunner starts and as a result the classes being tested have already been loaded.  I don't know much about the details beyond that.
> 
> [1]: https://github.com/robolectric/robolectric/blob/master/robolectric/src/main/java/org/robolectric/RobolectricTestRunner.java <https://github.com/robolectric/robolectric/blob/master/robolectric/src/main/java/org/robolectric/RobolectricTestRunner.java>
> 
> On Thu, May 14, 2015 at 5:34 PM, [email protected] <mailto:[email protected]> [junit] <[email protected] <mailto:[email protected]>> wrote:
>  
> I’d like need to use a custom ClassLoader for my tests. Can it be done?
> 
> Thanks,
> 
> 
> 
> Johannes.
> 
> 
> 
> 
> 
> 
>