Invoking Junit from an Ant script within Eclipse

J

junk

Hi,

I am having a problem with an Ant script I am creating in Eclipse. I
want it to run junit and so I have some entries like:

<target name="Test" depends="Compile">
<junit>
<test name="com.mycompany.myclass">
</junit>
</target>

When I run this within Eclipse I get an error because it does not seem
to recognise junit. The start of the error is

Ant could not find the task or a class this task relies upon.

I am using Eclipse 3.0.0 build 200403261517

Looking in the list of plugins I have ant-junit.jar under
org.apache.ant_1.6.1

Any ideas?

Thanks
Andy
 
M

Michiel Konstapel

When I run this within Eclipse I get an error because it does not seem
to recognise junit. The start of the error is

Ant could not find the task or a class this task relies upon.



You need a <taskdef> for junit.
HTH,
Michiel
 
J

junk

Thanks for that.

I have entered

<taskdef name="junit"
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

into the build.xml file but I get a warning message saying

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

Any ideas?

Thanks
Andy
 
Joined
Mar 4, 2009
Messages
1
Reaction score
0
Open MyEclipse click on Window->Prefrences->Ant->Runtime->Classpath->Ant Home Entries->Add Jars
Add the junit.jar here
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top