Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem setting Ant junit task

 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, All:
I am new to JUnit, but not so much to Ant. I got JUnit 3.8.1 today and ran succesfully a few tests, both with GUI or TextUI. However, I encountered a problem integrating Ant to Junit.
According to Ant's documentation, I put junit.jar into ANT_HOME/lib where ant.jar and optional.jar are. The following are what I have got when I started to run:
<target name="runtest">
<junit><test name="FirstHinTest"/></junit>
</target>

It first complains about not being able to creat task <junit>. I thought as long as optional.jar and junit.jar are in the ANT_HOME/lib, it should just recognize the junit as one of the optional Ant tasks and run it (that's the impression I got from documentation). Anyways, I put in
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
to define the tast and it showed me another error:
java.lang.NoClassDefFoundError: org/apache/tools/ant/ProjectComponent
Since this class is in ant.jar, so I put ANT_HOME/lib/ant.jar in the CLASSPATH. Then it gives me this error:
java.lang.VerifyError: (class: org/apache/tools/ant/taskdefs/optional/ide/VAJExp
ort, method: execute signature: ()V) Incompatible object argument for function call
This really get me stuck and puzzled. This looks like a mismatch in class definiations. I must be missing something seriously.
Any help is appreciated.
 
Irene Fernandez
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recently setup Ant using JUnit. [1]My first solution was to put the junit.jar in the ANT_HOME/lib directory. I do have a system environment variable set for ANT_HOME = C:\jakarta-ant-1.5 and no classpath. This worked. Have you checked your definition of ANT_HOME? [2]My second solution was to leave the junit.jar in the JUNIT_HOME. I have defined a classpath which includes: C:\Junit3.8.1\junit.jar and I have ANT_HOME = C:\jakarta-ant-1.5
Irene
 
Tony Yan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right. I have solved this problem a few days ago. The problem was my PC has been upgraded and I forgot to put int ANT_HOME. oops.
Thanks anyways.
 
vijay peyyala
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
When I run my ant test for a class from GUI through my IDE I get an "assertion failed" error when it is supposed to. But at the same instance if I run "ant junit" it shows me successful for the build. Please solve my problem.
Thanks n regards
vijay
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay, please don't crosspost a question into several threads.
Discussion related to Vijay's question should be continued in the other thread.
[ December 30, 2003: Message edited by: Lasse Koskela ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic