Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » No runnable method
No runnable method [message #62008] Sat, 16 May 2009 15:51 Go to next message
Michal Olejnik is currently offline Michal OlejnikFriend
Messages: 13
Registered: July 2009
Junior Member
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 22:11 Go to previous message
Michal Olejnik is currently offline Michal OlejnikFriend
Messages: 13
Registered: July 2009
Junior Member
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 22:11 Go to previous message
Michal Olejnik is currently offline Michal OlejnikFriend
Messages: 13
Registered: July 2009
Junior Member
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());
Previous Topic:repository name in artifacts.xml / content.xml
Next Topic:Invalid manifest files
Goto Forum:
  


Current Time: Fri Apr 19 23:43:45 GMT 2024

Powered by FUDForum. Page generated in 0.03022 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top