File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant and JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant and JUnit" Watch "Ant and JUnit" New topic

Ant and JUnit

Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
i wanted to run some testcases, and send the report to a folder named 'report'. when i try to run the script, ant doesnt recognise the junit tag, it throws an error
"Could not create task or type of type:junit"
"Ant could not find the task or a class this task relies upon."
Can any1 pls give me a small piece of code that runs a batchtest, including all the files in a directory, sending the report to some directory.

Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Do you have junit.jar in your ${ANT_HOME}/lib?
Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
thanks, i thought ant packs it with optional.jar. but theres another doubt now (might be a dumber 1) -
the testcases run, and the report keeps giving ClassNotFoundException for all my testcase classes. this is how my directory structure is -
lets say my project has only 1 package, xyz.
i hav a folder src, inside that a folder xyz, inside which the code resides. inside this src folder, theres another folder testcases, inside which the testcase code resides (the testcase classes r written with same package structure, ie., each test class will b in a package ... similarly, theres a 'bin' folder, and the same directory structure inside. these folders hold the compiled classes.
Should the ant script using junit tag point to the source directory, or to the compiled class files?
my junit task code contains something like
fileset dir="${src}" includes="**/*Test*.java"
will this take care of all the subfolders inside src?
I agree. Here's the link:
subject: Ant and JUnit
It's not a secret anymore!