At 08:02 PM 1/6/02 -0500, you wrote:
>If you drop all your dependent JAR's into ANT_HOME/lib (i.e. put junit.jar
>there) then you can (and should) run without a system specified classpath.
>
>So, just put junit.jar in your Ant installations lib directory and all
>should be well.
works great!
using the build below, it now says:
Buildfile: build.xml
init:
compile:
test:
[junit] Running MainTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] TEST MainTest FAILED
dist:
BUILD SUCCESSFUL
not sure why it says: Errors: 1, the test runs fine from the command line
sans ant. (prints out OK). is the junit step invoking some method in a
different way than: junit.textui.TestRunner.run(suite());?
thanks
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); }
}
<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="test" depends="compile">
<junit fork="yes" printsummary="on">
<test name="MainTest"/>
</junit>
</target>
<target name="dist" depends="test">
<mkdir dir="${dist}/lib"/>
<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
</target>
<target name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>
</project>
>----- Original Message -----
>From: "Ray Tayek" <[EMAIL PROTECTED]>
>To: "Ant Users List" <[EMAIL PROTECTED]>
>Sent: Sunday, January 06, 2002 7:33 PM
>Subject: Re: simple ant and junit fails
>
>
> > At 01:57 PM 1/6/02 -0500, you wrote:
> > >Two possible classic issues:
> > >
> > >- Did you download the "optional" Ant JAR file that contains the <junit>
> > >task itself?
> >
> > nope, duh! that's probably the problem. trying now, (i put the optional
>jar
> > where you said) but it still says the same thing:
> >
> > 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\JAKART~1.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:24: 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).
> >
> > Total time: 0 seconds
> >
> > using this build.xml:
> >
> > <project name="MyProject" default="dist" basedir=".">
> >
> > <!-- set global properties for this build -->
> > <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="test" depends="compile">
> > <!--
> > <classpath>
> > <pathelement path="${classpath}"/>
> > <pathelement location="junit.jar"/>
> > </classpath>
> > -->
> > <junit fork="yes">
> > <test name="MainTest"/>
> > </junit>
> > </target>
> >
> > <target name="dist" depends="test">
> > <mkdir dir="${dist}/lib"/>
> > <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar"
>basedir="${build}"/>
> > </target>
> >
> > <target name="clean">
> > <delete dir="${build}"/>
> > <delete dir="${dist}"/>
> > </target>
> > </project>
> >
> > >- Do you have junit.jar in your Ant classpath?
> >
> > not sure how to do this. is the commented example correct? i got the
> > junit.jar in the classpath on the compile step by using an attribute of
> > <javac...>, but anaict, there is no attribute for <junit...>.
> >
> > sorry to be so confused about this, but is not clear where all these
> > different classpaths go :(
> >
> > thanks
> >
> > >----- Original Message -----
> > >From: "Ray Tayek" <[EMAIL PROTECTED]>
> > >To: "Ant Users List" <[EMAIL PROTECTED]>
> > >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:[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]>
> >
> > ---
> > 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:[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]>
---
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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>