ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ray Tayek <rta...@mediaone.net>
Subject ant & junit works on win98, fails on deadrat 6.2
Date Mon, 28 Jan 2002 08:46:42 GMT
hi, i have a simple java Main and MainTest and a build.xml that works on 
win 98, but fails on deadrat 6.2 using junit 3.7 and ant 1.4.1 (which i 
built from source).

the classes compile and run junit from the command line just fine. but when 
i try to use ant to build, i get a:
package junit.framework does not exist.

thanks

Script started on Mon Jan 28 00:29:42 2002
.bashrc
[ray@k6 junit]$ bug
.bashrc

++ javac -classpath /usr/java/junit.jar Main.java MainTest.java

++ java -cp .:/usr/java/junit.jar MainTest
..
Time: 0.367

OK (2 tests)


++ ant
Buildfile: build.xml

init:

compile:
     [javac] Compiling 2 source files to /home/ray/junit/build
     [javac] /home/ray/junit/MainTest.java:1: package junit.framework does 
not exist
     [javac] import junit.framework.*;
     [javac] ^
     [javac] /home/ray/junit/MainTest.java:2: package junit.swingui does 
not exist
     [javac] import junit.swingui.*;
     [javac] ^
     [javac] /home/ray/junit/MainTest.java:3: cannot resolve symbol
     [javac] symbol  : class TestCase
     [javac] location: class MainTest
     [javac] public class MainTest extends TestCase
     [javac]                               ^
     [javac] /home/ray/junit/MainTest.java:8: cannot resolve symbol
     [javac] symbol  : class Test
     [javac] location: class MainTest
     [javac]     public static Test suite() { return new 
TestSuite(MainTest.class); }
     [javac]                       ^
     [javac] /home/ray/junit/MainTest.java:6: cannot resolve symbol
     [javac] symbol  : method assertNotNull  (Main)
     [javac] location: class MainTest
     [javac]     public void test1() { assertNotNull(new Main()); }
     [javac]                               ^
     [javac] /home/ray/junit/MainTest.java:7: cannot resolve symbol
     [javac] symbol  : method assertNotNull  (Main)
     [javac] location: class MainTest
     [javac]     public void test2() { assertNotNull(new Main()); }
     [javac]                               ^
     [javac] /home/ray/junit/MainTest.java:8: cannot resolve symbol
     [javac] symbol  : class TestSuite
     [javac] location: class MainTest
     [javac]     public static Test suite() { return new 
TestSuite(MainTest.class); }
     [javac]                                                 ^
     [javac] /home/ray/junit/MainTest.java:14: package junit.textui does 
not exist
     [javac]                     junit.textui.TestRunner.run(suite());
     [javac]                                     ^
     [javac] /home/ray/junit/MainTest.java:17: cannot resolve symbol
     [javac] symbol  : method getClass  ()
     [javac] location: class MainTest
     [javac]                     String[] string={ getClass().getName() };
     [javac]                                           ^
     [javac] /home/ray/junit/MainTest.java:18: package junit.swingui does 
not exist
     [javac]                     junit.swingui.TestRunner.main(string);
     [javac]                                      ^
     [javac] 10 errors

BUILD FAILED

/home/ray/junit/build.xml:12: Compile failed, messages should have been 
provided.

Total time: 20 seconds

++ cat 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); }
         }

++ cat 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 void test2() { assertNotNull(new Main()); }
         public static Test suite() { return new TestSuite(MainTest.class); }
         private void run_(String[] argument)
                 {
                 for(int i=0;i<argument.length;i++)
                         System.out.println("argument["+i+"]="+argument[i]);
                 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);
                 }
         }

++ cat 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"/>
   <path id="compileClasspath">
     <pathelement path="/usr/java"/>
     <pathelement location="junit.jar"/>
   </path>
   <target name="init"> <tstamp/> <mkdir dir="${build}"/> </target>
   <target name="compile" depends="init">
     <javac srcdir="${src}" destdir="${build}">
       <classpath refid="compileClasspath"/>
     </javac>
   </target>
   <target name="test" depends="compile">
     <junit fork="yes" printsummary="on"  haltonfailure="true">
       <classpath> <pathelement path="."/> </classpath>
           <test name="MainTest"/>
           <formatter type="brief" usefile="false"/>
     </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>
[ray@k6 junit]$
Script done on Mon Jan 28 00:30:31 2002

thanks

---
ray tayek http://home.earthlink.net/~rtayek/
actively seeking telecommuting work
orange county java users group http://www.ocjug.org/
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>


Mime
View raw message