Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-ui-dev] JUnit extension problem



>suggestions about retrieving the test-object in a
>more "Eclipse-like" fashion
The JUnit tests are run in a separate VM and therefore
the test object isn't and may not be instantiated in the
Eclipse VM at all.

You can analyze test classes using the JavaModel API,
e.g., find them in the workspace and do structural
analysis using the org.eclipse.jdt.core types.

--erich



                                                                           
             Philipp.Bouillon@                                             
             t-online.de                                                   
             Sent by:                                                   To 
             jdt-ui-dev-admin@         jdt-ui-dev@xxxxxxxxxxx              
             eclipse.org                                                cc 
                                                                           
                                                                   Subject 
             04/03/2003 11:14          [jdt-ui-dev] JUnit extension        
             AM                        problem                             
                                                                           
                                                                           
             Please respond to                                             
             jdt-ui-dev@eclips                                             
                   e.org                                                   
                                                                           
                                                                           




<I have already posted this topic (erroneously) in the eclipse.tools
newsgroup. Sorry for that.>

Hello,

I am trying to extend JUnit in Eclipse to perform some analysis of the
tests. So I thought of three different approaches which have (so far)
all
taken me into dead ends.
First, I implemented a new JUnit Launcher (by extending
org.eclipse.debug.core.launchConfigurationTypes). That worked quite
well,
until I had to access the workbench, and since I am a newbie, I have
not yet
figured out, how to access the Eclipse environment from an external
launcher
(but that's not my question here -- it was just my first attempt).
So, I changed my plans and developed an actionSet which was intendet
to
invoke the JUnit test, but here I ran into a strange problem: In my
actionSet implementation, I have the name of the Test class as a
string. So
I thought it would be possible to get an instance of that class by
using
Class.forName(nameOfTheTestClass); which produced a "class not found
exception". After I searched google, I found an article describing
this
problem (called "Understanding Class.forName). A solution would be to
use
Thread.currentThread().getContextClassLoader.loadClass(nameOfTheTestClass)
instead. However, this did not work either (I surrounded the statement
with
try/catch, of course). I also tried using Class.forName(name,
true/false,
getSystemLoader()) -- but that did not work either.
So, I changed my plans again and tried a third approach. This time I
extended "org.eclipse.jdt.junit.testRunListeners" but eventually ended
up
with the same problem: In my implementation of ITestRunListener
(precisely
in the method testFailed), I _need_ the junit.framework.Test object.
So
again, I was left with the problem of retrieving an object by its
name.
I tried it with a simple class (i.e.
Thread.currentThread().getContextClassLoader.loadClass(java.lang.Thread))
and it worked perfectly, so I assumed, it had something to do with my
classpath, so I set the classpath, and the user directory directly
before
calling the loadClass method, and still I receive a "class not found
exception".
I fear I am at a loss right now: I cannot think of any more things to
try to
load my class dynamically.
So, if you have any ideas about this problem, or if you have any
suggestions
about retrieving the test-object in a more "Eclipse-like" fashion, I
would
really be grateful.

Thanks for your time and suggestions,
Philipp Bouillon
_______________________________________________
jdt-ui-dev mailing list
jdt-ui-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-ui-dev




Back to the top