ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marko van Dooren <>
Subject Re: junit task not working
Date Fri, 14 Jun 2002 14:08:22 GMT
I posted this message a while ago, maybe it can help you. It adds the 
junit.jar to the classpath and forks the VM. You need the change the path to 
junit.jar of course, the org.jutil.jar  must be replaced by the jar/classpath 
that you are testing.

I managed to get the junit task to work without removing it from optional.jar 
and without putting it in the $ANT_HOME/lib directory. My solution might not 
be the most elegant and efficient one, but it works without much trouble.

These 3 targets do the job

<!-- Set ANT_OPTS to "" if is doesn't exist yet
      otherwise "${ANT_OPTS}" will be given to the
      java VM -->
<target name="antopts" unless="ANT_OPTS">
  <property name="ANT_OPTS" value=""/>

<!-- Set classpath correct, fork VM and call second test stage -->
<target name="test" depends="compile,antopts">
  <!-- Add junit.jar and org.jutil.jar to the classpath -->
  <property name="testpath"v 
  <!-- Run ant again with a different target, but fork the VM so we can add 
  jars to the classpath                                 

   See Ant documentation for reasons why it doesn't work when using <junit> 
  directly. -->
  <java classname="" fork="true" 
    <jvmarg line="-Dant.home=${ant.home} ${ANT_OPTS}"/>
    <arg line="test-secondstage"/>

<target name="test-secondstage" depends="init">
  <!-- perform tests here -->

I'm not sure whether it is cross-platform or not, I only use linux.

Happy junit testing,

Marko No. 5
-- - Programming as you know it is over

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message