Running JUnit under Ant? Read This.

After a long break from using Ant and JUnit together to solve all the development woes that trouble me, I have recently reunited this duo. However, the reunion didn’t immediately prove productive, as I had hoped. I received the following error message:

/home/steve/workspace/dss/build.xml:152: Could not create task or type of type: junit.

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

And then a very long, and (as it turns out) useless message about making sure that JARs were in the right place and so on and so forth. Then I found a post that helped me. Apparently, the ant-junit.jar that comes with the Ant distro (and the Ant Debian package, which I had been using until I gave up, removed it, and used the distro directly) doesn’t quite have what it takes. You also need to use the junit.jar that comes with the JUnit distro.

Here is the fix:

Get ahold of junit.jar. Try here.
Copy the junit.jar from the distro into ${ANT_HOME}/lib

That’s it. Seriously. I suppose all that is contained in ant-junit.jar is the bare-bones JUnit interface. For the rest you still need to have JUnit on the CLASSPATH somewhere, and copying it into ${ANT_HOME}/lib does the trick.

Have fun.


One thought on “Running JUnit under Ant? Read This.

  1. I’ve been working on a project called fant in, and it helps me to create projects, just simplify the dev process, and it leverage the maven repository, can handle all the dependencies of the project, hope one day you can take look at it. 🙂

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.