No runnable method [message #62008] |
Sat, 16 May 2009 11:51  |
Eclipse User |
|
|
|
Hello,
i'm currently writing a plugin which is supposed to launch JUnit4 Tests
after each save. So far i'm only loading every class that is changed using
IResourceChangedListener and URLClassLoader:
URLClassLoader classLoader = new URLClassLoader(new URL[]
{outputDirectory.toURL(), new
URL("file:/D:/eclipse/plugins/org.junit4_4.3.1/junit.jar") });
Class<?> clazz = classLoader.loadClass(fileName);
At this point everything looks great - when i modify JUnit4 test class it
gets loaded with annotations on proper methods (thanks to second URL -
without it no annotation was loaded, and to be honest i don't know why).
However, things start to go wrong when i pass the loaded class to
JUnitCore.run method - the result i always get says that there was "No
runnable method" exception even though there are clearly some method
annotaded with @Test...
I have little experience in writing plugins for Eclipse, so i'm kind of
lost now... I may suspect, that the problem is with not sufficient
classpath (cause it seems that it was a reason why i had to add another
URL to class loader) of my plugin. So i'm asking if anyone ever tried to
dynamically load test classes from Eclipse plugin and run them using
JUnitCore - if so, I'd be very grateful for helping me out with this
problem.
Thanks in advance.
Best regards,
Michal Olejnik
|
|
|
Re: No runnable method [message #62101 is a reply to message #62008] |
Sat, 16 May 2009 18:11  |
Eclipse User |
|
|
|
I found a solution - it seems that when you load annotations from the same
jar but with different class loaders, they're treated as different even
though they're the same...
all i had to do was:
URLClassLoader classLoader = new URLClassLoader(new URL[]
{outputDirectory.toURL()} JUnitCore.class.getClassLoader());
|
|
|
Re: No runnable method [message #597593 is a reply to message #62008] |
Sat, 16 May 2009 18:11  |
Eclipse User |
|
|
|
I found a solution - it seems that when you load annotations from the same
jar but with different class loaders, they're treated as different even
though they're the same...
all i had to do was:
URLClassLoader classLoader = new URLClassLoader(new URL[]
{outputDirectory.toURL()} JUnitCore.class.getClassLoader());
|
|
|
Powered by
FUDForum. Page generated in 0.03345 seconds