Using ScalaTest

JUnit is a good starting point for unit testing Scala code. However, as you get more familiar with Scala, you’ll want to take advantage of Scala’s conciseness and idioms for unit testing as well. When you’re ready for that, you may want to graduate to using ScalaTest. ScalaTest is a testing framework written in Scala by Bill Venners, with contribution from many other developers. It provides concise syntax for assertions and functional style for testing both Scala and Java code.

ScalaTest doesn’t ship with Scala, so first you need to download it.[7] Once you download the JAR, set an environment variable, SCALA_TEST_JAR, to refer to the full path of that JAR.

Now that you’ve downloaded ScalaTest, let’s write a test, similar to ...

Get Pragmatic Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.