ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: simple ant and junit fails
Date Sun, 06 Jan 2002 18:57:27 GMT
Two possible classic issues:

- Did you download the "optional" Ant JAR file that contains the <junit>
task itself?

- Do you have junit.jar in your Ant classpath?

Both appear to be no in the output you've shown.  Put the both JAR's in
ANT_HOME/lib and you'll be set.

    Erik

----- Original Message -----
From: "Ray Tayek" <rtayek@mediaone.net>
To: "Ant Users List" <ant-user@jakarta.apache.org>
Sent: Sunday, January 06, 2002 1:39 PM
Subject: simple ant and junit fails


> hi, new to ant. tried to add a junit to the sample build.xml in the doc.
> getting the following when using the build.xml below. the junit stuff
works
> ok if i run it by hand using java -cp .;d:/classpath/junit.jar;. MainTest
>
>
> BUILD FAILED
> D:\usr\ray\java\junit\build.xml:22: Could not create task of type: junit.
> Common solutions are to use taskdef to declare your task, or, if this is
an
> optional task, to put the optional.jar in the lib directory of your ant
> installation (ANT_HOME).
>
>
> D:\usr\ray\java\junit>ant
> "C:\jdk1.3.1_01\bin\java" -classpath
>
"C:\jdk1.3.1_01\lib\tools.jar;D:\ant\lib\JAXP.JAR;D:\ant\lib\CRIMSON.JAR;D:\
ant\lib\ANT.JAR;d:\classpath"
>   -Dant.home="D:\ant"  org.apache.tools.ant.Main
> Buildfile: build.xml
> init:
> compile:
> test:
> BUILD FAILED
> D:\usr\ray\java\junit\build.xml:22: Could not create task of type: junit.
> Common solutions are to use taskdef to declare your task, or, if this is
an
> optional task, to put the optional.jar in the lib directory of your ant
> installation (ANT_HOME).
>
> //build.xml:
> <project name="MyProject" default="dist" basedir=".">
>
>    <property name="src" value="."/>
>    <property name="build" value="build"/>
>    <property name="dist"  value="dist"/>
>    <property name="test"  value="test"/>
>
>    <target name="init">
>      <tstamp/>
>      <mkdir dir="${build}"/>
>    </target>
>    <target name="compile" depends="init">
>      <javac srcdir="${src}" destdir="${build}"
> classpath=".;d:/classpath/junit.jar"/>
>    </target>
>
>    <target name="dist" depends="test">
>      <mkdir dir="${dist}/lib"/>
>      <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar"
basedir="${build}"/>
>    </target>
>
>    <target name="test" depends="compile">
>      <junit fork="yes">
>        <test name="MainTest" />
>      </junit>
>    </target>
>
>    <target name="clean">
>      <delete dir="${build}"/>
>      <delete dir="${dist}"/>
>    </target>
> </project>
>
> //Main.java:
> import java.util.*;
> class Main
>          {
>          public void run(String[] argument) {
> System.out.println(this.getClass().getName()+" started at "+new Date()); }
>          public void main(String[] argument) { (new
Main()).run(argument); }
>          }
>
> //MainTest.java:
> import junit.framework.*;
> import junit.swingui.*;
> public class MainTest extends TestCase
>          {
>          public MainTest(String name)
>                  { super(name); }
>          public void test1()
>                  { assertNotNull(new Main()); }
>          public static Test suite()
>                  { return new TestSuite(MainTest.class); }
>          private void run_(String[] argument)
>                  {
>                  if(true)
>                          junit.textui.TestRunner.run(suite());
>                          else
>                          {
>                          String[] string={ getClass().getName() };
>                          junit.swingui.TestRunner.main(string);
>                          }
>                  }
>          public static void main(String[] argument)
>                  {
>                  (new MainTest("run_")).run_(argument);
>                  }
>          }
>
> ---
> ray tayek http://home.earthlink.net/~rtayek/
> orange county java users group http://www.ocjug.org/
> want privacy? http://www.freedom.net/
> hate spam? http://samspade.org/ssw/
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message