ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (David M. Karr)
Subject Basic setup of Junit in Ant?
Date Mon, 25 Feb 2002 21:44:29 GMT
I've been using Ant for basic building, packaging, and manual tests.  I'd now
like to set up to use JUnit.

I'm having trouble understanding exactly what I have to put in the "build.xml"
file, setting up external dependencies, and finally, how to actually RUN the

Of all the documentation I've found, I can't find anything that says clearly
what element the "junit" element is in.  I would guess it's a subelement of the
"project" element, but I can't confirm that from the documentation.

I'm using JDK 1.4 and Ant 1.4.  I've put "jakarta-ant-1.4-optional.jar" in the
$ANT_HOME/lib directory.

When I run "ant", I get the error:

  Unexpected element "junit"

Here is my "build.xml" file:
<?xml version="1.0" encoding="UTF-8" ?>
<project name="myproj" default="compile" basedir=".">
 <property name="junit.home" value="$(env.JUNIT_HOME)" />
 <target name="compile">
  <mkdir dir="classes"/>
  <javac srcdir="src" destdir="classes"
			debug="on" optimize="off" deprecation="on">
   <include name="**/*.java"/>
 <junit printSummary="yes" haltOnFailure="yes">
   <pathelement location="classes"/>
   <pathelement location="${junit.home}/junit.jar"/>
  <formatter type="plain" />
  <batchtest fork="yes" todir="reports">
   <fileset dir="src">
    <include name="**/*Test*.java" />
    <exclude name="**/" />

David M. Karr          ; Java/J2EE/XML/Unix/C++

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

View raw message