FAQ

[Ant-user] <junit> failing when used with ANT version 1.6.2 ( error : org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found: junit/framework/Test )

Srinivasan krishnan
Feb 4, 2008 at 11:52 pm
Hello,
I am trying to use <junit> target from ANT v 1.6.2 and am getting this
error.

taskdef A class needed by class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found:
junit/framework/Test


I have read the solution on the ant website under faq and tried to taskdef
my junit
and include all jar files ( including junit.jar and ant-junit.jar ) into my
classpath .

I have no optionals.jar anywhere in my path ..I guess this jar doesnt come
with ant version 1.6.

I appreciate any help to help me run junit tests using ANT.
I have included the verbose ant output..


<taskdef name="junit"
classname="
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
* <classpath>
<fileset dir="/opt/bea/wl9.2.0/weblogic92/server/bin/lib">
<include name="*.jar" />
</fileset>
</classpath>*
</taskdef>




*Commandline leading to error:

*ant -f buildTest.xml -lib ~/.ant/lib run-tests -verbose
Apache Ant version 1.6.2 compiled on August 5 2004
Buildfile: buildTest.xml
Detected Java version: 1.5 in: /opt/bea/wl9.2.0/jrockit-jdk1.5.0_06/jre
Detected OS: Linux
parsing buildfile /sep/java/buildTest.xml with URI =
file:///sep/java/buildTest.xml
Project base dir set to: /sep/java
[property] Loading /sep/java/buildTest.properties
Override ignored for property src.dir
Override ignored for property build.dir
Override ignored for property classes.dir
Override ignored for property lib.dir
dropping /sep/java/lib/thirdparty_tools/XmlBeans/lib/*.jar from path as it
doesn't exist

BUILD FAILED
/sep/java/buildTest.xml:200: taskdef A class needed by class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found:
junit/framework/Test
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.helper.ProjectHelper2.parse(
ProjectHelper2.java:133)
at org.apache.tools.ant.ProjectHelper.configureProject(
ProjectHelper.java:91)
at org.apache.tools.ant.Main.runBuild(Main.java:658)
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)
Caused by: java.lang.NoClassDefFoundError: junit/framework/Test
at java.lang.Class.forName(Ljava.lang.String;ZLjava.lang.ClassLoader;)Ljava.lang.Class;(Unknown
Source)
at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java
:457)
... 10 more
--- Nested Exception ---
java.lang.NoClassDefFoundError: junit/framework/Test
at java.lang.Class.forName(Ljava.lang.String;ZLjava.lang.ClassLoader;)Ljava.lang.Class;(Unknown
Source)
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.helper.ProjectHelper2.parse(
ProjectHelper2.java:133)
at org.apache.tools.ant.ProjectHelper.configureProject(
ProjectHelper.java:91)
at org.apache.tools.ant.Main.runBuild(Main.java:658)
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)

Total time: 1 second
reply

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post

1 user in discussion

Srinivasan krishnan: 1 post