ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marko van Dooren <Marko.vanDoo...@cs.kuleuven.ac.be>
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=""/>
</target>

<!-- 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 
alue="${java.class.path}:${lib}/junit.jar:${lib.dist}/org.jutil.jar"/>
  <!-- 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="org.apache.tools.ant.Main" fork="true" 
    classpath="${testpath}">
    <jvmarg line="-Dant.home=${ant.home} ${ANT_OPTS}"/>
    <arg line="test-secondstage"/>
  </java>
 </target>

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


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

Happy junit testing,
------------------------------------------------------------------------------------------------


Marko No. 5
-- 
Jutil.org - Programming as you know it is over
http://org-jutil.sourceforge.net

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message