Archive for December, 2006

Running JUnit under Ant? Read This.

Posted in Open Source, Software Development on December 11, 2006 by jstevenperry

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.