ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Michali <>
Subject Re: Looking for Ant references/examples
Date Fri, 05 Oct 2001 19:19:48 GMT

> 3. How to automate testing with JUnit.

Go to the JUnit home page & follow instructions to install and set up
your own JUnit tests. (

In Ant, you can add a JUnit target. Here's what I use:

<target name="test" if="junit.present" 
	description="Runs the JUnit test cases">
	<junit fork="yes" printsummary="no" haltonfailure="yes">
		<jvmarg value="-Dtest.home=${test.classes.dir}/pathfinder"/>
		    <pathelement path="${classes.dir}" />
		    <pathelement path="${test.classes.dir}" />
	            <pathelement path="${test.classes.dir}/pathfinder" />
		    <path refid="test.classpath" />
		<formatter type="plain" usefile="false" />
		<test name="${}" />

I have a target to build the test code and then the JUnit target
depends on this (and on a custom task that starts a mail server I
use in my tests). I pass in a property (test.home) for my test
app. I also add class path entries that point to my production
class files, test class files, property files, and other paths and
JARS used by the test app.

You'll need to setup your classpath based on how you layout your
tree structure (I put the test code as a sub-directory under the
project; so I have a src dir and then a src/test dir).

I think the Ant docs show a target with JUnit, so you may want to
nose around to see what's there.

PCM (Paul Michali)

Carrier Voice Gateway Business Unit (CVGBU)
Cisco Systems, Inc.
250 Apollo Drive
Chelmsford, MA 01824

Phone : (800) 572-6771 x 45817  (978) 244-5817 [direct]
Paging: (800) 365-4578 [voice] [email page]

View raw message