The promise of increased testing efficiency is at the heart of ScalaTest, an open-source testing framework released today by Artima. ScalaTest makes testing more effective because it provides higher-level abstractions for common test-related developer tasks, says ScalaTest creator Bill Venners:
ScalaTest 1.0 is a Scala application that enables developers to work at a
higher level than JUnit and TestNG when writing tests. ScalaTest 1.0 runs on the JVM and can be used to test Java as well as Scala code. In addition to deep integration with JUnit and TestNG, it also supports an Ant task, integrates with maven, and includes improved syntax for popular Java mocking frameworks JMock, EasyMock, and Mockito. Via its JUnit integration ScalaTest can easily be used with IDEs such as Eclipse, NetBeans, and IntelliJ IDEA and productivity tools such as Infinitest.
In addition, ScalaTest also supports multiple testing styles:
Because different developers take different approaches to creating software, ScalaTest is designed to facilitate different styles of testing. ScalaTest provides several traits that you can mix together into whatever combination makes you feel the most productive.
Finally, ScalaTest provides a low-risk way to introduce the Scala language in an organization with large amounts of existing Java code. Properly testing Java code can require three times the lines of code being tested. The Scala language promises a more concise codebase. Combined with its high-level testing abstractions, ScalaTest can make testing Java libraries or classes more effective.
What do you think of using Scala for unit testing both Java and Scala code? And what is your take on ScalaTest's multi-paradigm approach to testing?
I actually use Scala and specs for testing Java code with an inclination to ScalaCheck for random testing. I'm still looking for frameworks which make testing concurrent code easier. The Scala compiler (2.7.6) is however annoyingly slow.
> I actually use Scala and specs for testing Java code with > an inclination to ScalaCheck for random testing. I'm still > looking for frameworks which make testing concurrent code > easier. > Testing of concurrent code is a focus of ScalaTest. The 1.0 release has a class called Conductor that is our first step in that direction. Conductor aims to make it easier to test classes you write that are supposed to be thread safe. Later we're hoping to have a Director that does a similar thing for Actors based code. You can read about it here:
It isn't exactly the same (because it is nicer), but it has some overlap with a specs Specification. There are also a few other BDD styles in ScalaTest that specs does not have. You can see an overview here:
I should put up a page comparing specs and ScalaTest, so it is easier for people to see the differences. Here's Jonas Boner's tweet about the difference:
> The Scala compiler (2.7.6) is however annoyingly slow. > It sure is. ScalaTest can run tests in parallel on multiple cores but still sort the results in sequential order afterwords, in an effort to speed up tests the more cores you get, but I think there needs to be some attention to making the compiler go faster after they get the 2.8 release out.