ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marko van Dooren <>
Subject JUnit task can work without fighting with jars or taskdefs
Date Thu, 16 May 2002 10:15:26 GMT
First of all, sorry for posting on both lists, but I think developers will be 
interested also because they might want to update the documentation.

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