Wednesday, March 7, 2007

junit ant task problems in eclipse

So your junit ant task won't run, failing with classpath problems. How hard can that be to figure out? It sure stumped me for a while.

You figure you need ant-junit.jar on the classpath. Hmmm, is that the project classpath (a lib dir maybe)? Or the ant home dir? But wait, it's already there... so what's the problem.

The problem is that ant-junit.jar is not self-contained, as I naively assumed. You need to supply the junit.jar file to ant, which is referenced by ant-junit.jar. Make sense when you think about it--but in the haze of red error messages whizzing by, it's easy to miss. Anyway, it's easy to fix, as documented in this blog post.

Thanks Ryan!

No comments: