You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jonathan Carlson <jc...@is.com> on 2000/10/30 21:05:46 UTC

Simple question about jUnit task forking

I'm sorry to be asking such a simple question that has probably been asked
before, but I'm stuck.  When I try to fork the jUnit task I get the
following error:
 
[junit] java.lang.NoClassDefFoundError:
org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner
 
Why will it find the class when I don't fork it, but it won't find it when I
do fork it?  I have to fork it because I have to pass in a JVM parameter.
The junit.jar file is definitely in my NT environment classpath and it is
also in the task classpath.
 
Thanks in advance for any tips given!  :-)
 

Jonathan Carlson,  Software Developer 
jcarlson@is.com 

Such ever was loves way: to rise, it stoops.   
     - Robert Browning 


 

Re: Simple question about jUnit task forking

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "JC" == Jonathan Carlson <jc...@is.com> writes:

 JC> Why will it find the class when I don't fork it, but it won't
 JC> find it when I do fork it?

If you don't fork it, you are running junit in the same VM as
Ant. Ant's junit classes are in ant.jar or optional.jar which are
included by your Ant wrapper script automatically.

Solutions:

(1) Add ant.jar and optional.jar to your CLASSPATH environment
variable.

(2) Invoke junit like this

<junit fork="yes">
  <classpath>
    <pathelement path="${java.class.path}" />
  </classpath>
...
</junit>

this will ensure the Ant classes are in your CLASSPATH.

I'd recommend option (2).

Stefan