<junit> is a task, and therefore it must be inside a <target> just like all
tasks (except data type definitions, <property>, <taskdef>, and <typedef>).
You will need to download the optional Ant JAR and put junit.jar in your
Ant's lib directory.
Erik
----- Original Message -----
From: "David M. Karr" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 25, 2002 4:44 PM
Subject: Basic setup of Junit in Ant?
> 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
> tests.
>
> 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"/>
> </javac>
> </target>
> <junit printSummary="yes" haltOnFailure="yes">
> <classpath>
> <pathelement location="classes"/>
> <pathelement location="${junit.home}/junit.jar"/>
> </classpath>
> <formatter type="plain" />
> <batchtest fork="yes" todir="reports">
> <fileset dir="src">
> <include name="**/*Test*.java" />
> <exclude name="**/AllTests.java" />
> </fileset>
> </batchtest>
> </junit>
> </project>
> ----------------
>
> --
> ===================================================================
> David M. Karr ; Java/J2EE/XML/Unix/C++
> [EMAIL PROTECTED]
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>