I’m a long-time Eclipse user, but I heard that NetBeans has better (for the time being) Groovy support. To see what it was all about I downloaded and installed NetBeans 6.7.1. While I was attending the No Fluff Just Stuff conference this weekend I tried following along with a Groovy testing session by plugging the examples into NetBeans. We created a mix of Java and Groovy tests inside a Java project, but when I ran the test suite only the Java tests ran.
I dug through the generated build-impl.xml file to find out why, and found that JUnit is being passed a list of .java files. The Groovy tests are .groovy, so they won’t run. JUnit will accept .class files, and since Java and Groovy are compiled to .class files by NetBeans tests in both languages will run this way. I edited build.xml and overrode three targets from build-impl.xml. With these changes you can run individual Java and Groovy tests or run them as part of a full test run. I highlighted the changes I made from the original build-impl.xml targets in red. If you copy/paste the xmlns attribute and these targets into build.xml you should be able to run all of your Groovy and Java tests in NetBeans.
Note: Be sure to edit build.xml, not build-impl.xml since it can regenerate and overwrite your changes. Yes, I found this out the hard way 🙂