Neal Ford presented several ideas, tools and libraries for more productive Java unit testing at Oredev 2010.
Ford suggested going outside the box and looking at writing unit tests in other JVM languages even if the target language is Java. “Always test a weaker language with a stronger one”, said Ford, suggesting that people should use Groovy to write Java unit tests. According to him, Groovy makes writing unit tests easier because it ignores privates and exceptions. Another option is JRuby. “Ruby guys have the coolest testing tools in the world”, said Ford. Java developers can use those tools with the help of JTestR, which makes it easy to write Java unit tests in JRuby and use standard Ruby testing tools for Java projects.
For teams working with J2EE technologies, he suggested using Mockrunner, which “stubs out J2EE by magic”, according to Ford. Mockrunner has stubs that provide out of the box functionality for JMS, JDBC, Servlet and many other J2EE APIs. It should allow unit testing of code that depends on J2EE APIs outside a container.
For teams that work with the Spring stack and related APIs, he suggested using Unitils, a “swiss army chainsaw of useful stuff”. It supports stubbing out Hibernate, Spring, JPA and similar APIs to speed up unit testing without having to really load the spring context or work against a database


I’m sorry but I don’t get it:why to use suites written in languages other than Java(even if those “other languages” are java based) for writing unit tests for an application that I make using Java?I mean,there probably are many wonderful testing suites out there written in Ruby etc,but since I’m making an application using Java,wouldn’t make more sense to use tools written in java to write my unit test?
I think that using groovy to write unit tests for java can be a good thing, so that we dont have to change the production code to make things available to the unit tests. i havent have the time to look into groovy jet, but its my ompression that it is pretty similar to java, so writing tests in groovy shouldnt be much of a challenge to a java programmer.
When it comes to using a totally different programming language, like ruby, i think learning another language just to write tests can be a challenge.
Personally, i am having problems communicating to our testers, what the unit tests test, and what we leave for them to test. If another language have better tools, to facilitate this communication between programmers and testers, or others, i would be happy to learn another language.
Its my impression that automated acceptance tests gives more bang for the bucks, specially in terms of confidence in the tests.
This is just some thoughts from a beginner in agile test automation
@Nikos
If another language has fantastic testing tools then it makes sense to leverage them to test your own code even if it means using a different language.
Using less verbose languages like Ruby and the test libraries available to it also mean that your tests are more concise, quicker to write (Very important) and easier to understand.