You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Yoshimitsu, Stacy D." <SY...@northropgrumman.com> on 2003/05/09 01:00:45 UTC

Running junit in Ant

Hello,

I'm trying to implement junit test into my build.xml file.  I didn't want to
copy the junit.jar file over to Ant/lib directory because I'm doing 2-3
projects build and each maybe using a different version of junit.  I've
looked at Ant's document and it saids:  

Note: You must have junit.jar and the class files for the <junit> task in
the same classpath. You can do one of: 
	Put both junit.jar and the optional tasks jar file in ANT_HOME/lib. 
	Do not put either in ANT_HOME/lib, and instead include their
locations in your CLASSPATH environment variable. 
	Do neither of the above, and instead, specify their locations using
a <classpath> element in the build file. See the FAQ <../../faq.html> for
details. 


So, I've looked at option 3 (to remove junit class files from optional.jar).
I first extracted optional.jar --> remove all junit class files --> jar up
optional.jar file and places it in Ant/lib directory --> run build.xml and
got the following message:

_____________________________________________________________
Invalid implementation version between Ant core and Ant optional tasks.
 core    : 1.5.1
 optional: null
______________________________________________________________

Does anyone know how I can fix that errors?  How is everyone doing w/ their
junit test in Ant?  What can I do if I don't want to copy junit.jar file to
Ant/lib directory?  This is what I have in the build.xml file:

____________________________________________________________
<target name="run.junit.test" depends="init" description="Run JUnit test" >
    <junit printsummary="off" 
	   haltonfailure="true"
	   showoutput="yes" 
	   fork="true" >

	<classpath>
	    <fileset dir="${libs.dir}" >
	  	<include name="*.jar" />
	    </fileset>
	    <fileset dir="${classes.dir}" >
	  	<include name="*.xml" />
	    </fileset>
	</classpath>
	<classpath path="${classes.dir}" />

	<formatter type="brief" usefile="false" />
	<test name="com.northropgrumman.amm.test.TestSuiteMain"  />
    </junit>
</target

____________________________________________________________


Thanks,

Stacy

Re: Running junit in Ant

Posted by Jesse Stockall <st...@magma.ca>.
On Thu, 2003-05-08 at 19:00, Yoshimitsu, Stacy D. wrote:
> 
> 
> So, I've looked at option 3 (to remove junit class files from optional.jar).
> I first extracted optional.jar --> remove all junit class files --> jar up
> optional.jar file and places it in Ant/lib directory --> run build.xml and
> got the following message:
> 
> _____________________________________________________________
> Invalid implementation version between Ant core and Ant optional tasks.
>  core    : 1.5.1
>  optional: null
> ______________________________________________________________
> 
> Does anyone know how I can fix that errors?  How is everyone doing w/ their
> junit test in Ant?  What can I do if I don't want to copy junit.jar file to
> Ant/lib directory?  This is what I have in the build.xml file:
> 

You need to use the manifest that shipped with Ant when you re-jar the
classes. It contains the version of the tasks.

Most people put junit.jar in ANT_HOME/lib, it's by far the easiest.

The other option is to put junit.jar and optional.jar in the <classpath>
of the <junit> target. This can be pain if you want to use optional
tasks in other parts of the build.

The next version of Ant has the optional tasks broken up into separate
jars, for just this situation. 

-- 
Jesse Stockall <st...@magma.ca>