ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From AjayaSa...@TDWaterhouse.com
Subject Unable to create junit task with ant 1.6.2 & junit3.8.1
Date Fri, 29 Oct 2004 15:17:06 GMT
Hi,

 

I am using ant-1.6.2 & junit-3.8.1 and unable to create the junit task. I
have looked into the archive and put both junit  

 

<project name="sampling" default="test">

 

  <property file="build.properties"/>

 

  <property name="src.dir" location="src"/>

  <property name="src.java.dir" location="${src.dir}/java"/>

  <property name="src.test.dir" location="${src.dir}/test"/>

 

  <property name="target.dir" location="target"/>

  <property name="target.classes.java.dir" 

      location="${target.dir}/classes/java"/>

  <property name="target.classes.test.dir" 

      location="${target.dir}/classes/test"/>

 

  <property name="target.report.dir" 

      location="${target.dir}/report"/>

 

  <property name="junit.jar"
location="../repository/junit/jars/junit-3.8.1.jar"/>

  <property name="junit.dir" location="../repository/junit/jars/"/>

 

  <property name="ant.lib.dir" location="C:\apache-ant-1.6.2\lib/"/>

 

  <target name="compile.java">

    <mkdir dir="${target.classes.java.dir}"/>

    <javac destdir="${target.classes.java.dir}">

      <src path="${src.java.dir}"/>

    </javac>

  </target>

 

  <target name="compile.test" depends="compile.java">

    <mkdir dir="${target.classes.test.dir}"/>

    <javac destdir="${target.classes.test.dir}">

      <src path="${src.test.dir}"/>

      <classpath>

        <pathelement location="${target.classes.java.dir}"/>

        <pathelement location="${junit.jar}"/>

      </classpath>

    </javac>

  </target>

 

  <target name="compile" depends="compile.java,compile.test"/>

 

  <target name="test" depends="compile">

    <mkdir dir="${target.report.dir}"/>

    <property name="tests" value="TestDefaultController"/>

 

<path id="junit.cp">

   <fileset dir="${junit.dir}">

      <include name="junit-3.8.1.jar"/>       

   </fileset>

   <fileset dir="${ant.lib.dir}">

      <include name="ant-junit.jar"/>         

   </fileset>

 

</path>

 

<taskdef name="junit"             

classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"

classpathref="junit.cp"/>

 

 

    <junit printsummary="yes" haltonerror="yes" haltonfailure="yes"
fork="yes">

      <formatter type="plain" usefile="false"/>

      <formatter type="xml"/>

      <batchtest todir="${target.report.dir}">

        <fileset dir="${src.test.dir}">

          <include name="**/${tests}.java"/>

          <exclude name="**/Test*All.java"/>

        </fileset>

      </batchtest>

      <classpath>

        <pathelement location="${target.classes.java.dir}"/>

        <pathelement location="${target.classes.test.dir}"/>

        <pathelement path="${ant.home}/lib/clover.jar"/>

        <pathelement location="${junit.jar}"/>

      </classpath>

    </junit>

  </target>

 

  <target name="report" depends="test">

    <mkdir dir="${target.report.dir}/html"/>

    <junitreport todir="${target.report.dir}">

      <fileset dir="${target.report.dir}">

        <include name="TEST-*.xml"/>

      </fileset>

      <report todir="${target.report.dir}/html"/>

    </junitreport>

  </target>

 

  <target name="clean">

    <delete dir="${target.dir}"/>

  </target>

 

<!--

  <target name="clover.init">

    <taskdef resource="clovertasks"/>

    <clover-setup initString="${target.dir}/clover_coverage.db">

      <files>

        <exclude name="**/Test*.java"/>

      </files>

    </clover-setup>

  </target>

 

  <target name="clover" depends="clean,clover.init,test">

    <clover-report>

      <current outfile="${target.dir}/clover" title="Clover Report">

        <format type="html"/> 

      </current>   

    </clover-report>

  </target>

-->

</project>

 

I get the following error while creating the junit task:

 

fileset: Setup scanner in dir C:\junitbook\repository\junit\jars with
patternSet{ includes: [jun

.8.1.jar] excludes: [] }

fileset: Setup scanner in dir C:\apache-ant-1.6.2\lib with patternSet{
includes: [ant-junit.jar]

ludes: [] }

Class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask loaded from
parent loader (parentFi

 

 

BUILD FAILED

C:\junitbook\sampling\build.xml:59: taskdef A class needed by class
org.apache.tools.ant.taskdef

tional.junit.JUnitTask cannot be found: junit/framework/TestListener

        at
org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:487)

        at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)

        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

        at org.apache.tools.ant.Task.perform(Task.java:364)

        at org.apache.tools.ant.Target.execute(Target.java:341)

        at org.apache.tools.ant.Target.performTasks(Target.java:369)

        at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

        at org.apache.tools.ant.Project.executeTargets(Project.java:1062)

        at org.apache.tools.ant.Main.runBuild(Main.java:673)

        at org.apache.tools.ant.Main.startAnt(Main.java:188)

        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)

        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

--- Nested Exception ---

java.lang.NoClassDefFoundError: junit/framework/TestListener

        at java.lang.ClassLoader.defineClass0(Native Method)

        at java.lang.ClassLoader.defineClass(ClassLoader.java:703)

        at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)

        at java.net.URLClassLoader.defineClass(URLClassLoader.java:319)

        at java.net.URLClassLoader.access$400(URLClassLoader.java:92)

        at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:677)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.net.URLClassLoader.findClass(URLClassLoader.java:238)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:516)

        at java.lang.ClassLoader.loadClass(ClassLoader.java:448)

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:220)

        at
org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)

        at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)

        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

        at org.apache.tools.ant.Task.perform(Task.java:364)

        at org.apache.tools.ant.Target.execute(Target.java:341)

        at org.apache.tools.ant.Target.performTasks(Target.java:369)

        at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

        at org.apache.tools.ant.Project.executeTargets(Project.java:1062)

        at org.apache.tools.ant.Main.runBuild(Main.java:673)

        at org.apache.tools.ant.Main.startAnt(Main.java:188)

        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)

        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

Thanks,

Ajaya 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message