views:

675

answers:

1

I'm familiar with using mock objects to help unit test my Java types, but find the inflexibility can lead to verbose and cumbersome test types and a lot of repetition.

I've looked at using Groovy for unit tests with moderate success. I'm interested in learning Scala for itself, but would also like some advice on using it for testing Java. Does anyone have any advice or references on using Scala to do this?

Update to clarify what I'm after:

I've seen that there exists tools for unit testing in Scala, like ScalaTest. and ScalaCheck, but they focus on how to do the mechanics of testing. I'm looking for some best-practices and/or hints and tips for how unit testing should be approached with Scala. For example an equivalent of the Javaworld JUnit best practices article or a list of anti-patterns to point out common pitfalls or useful conventions.

+3  A: 

You can certainly use Scala to test Java. In fact, since the Scala testing frameworks integrate well with JUnit, you can write the tests in Scala, and run them from Eclipse through JUnit.

There are three important frameworks: ScalaTest, general, very flexible; ScalaCheck, based on a Haskell testing framework, it generate random data to test conditions for you; Specs, general, similar in scope to ScalaTest, but has a more BDD-oriented syntax.

Daniel
I know it is possible, I was looking for some guidance on doing so, sorry if that wasn't clear from my question.
Rich Seller