Thinking > story

Using ScalaTest in a Play Framework Application

The Play Framework is configured out of the box for specs2. However, some people (including the author) prefer ScalaTest. Play actually doesn't really care what testing framework you use, but there is one gotcha you need to know about.

The default Play configuration sets the test options sequential true junitxml console, which are specific to specs2. Because ScalaTest doesn't understand these options, you need to specify testOptions in Test := Nil in your build definition.

Starting with Play 2.2, build.sbt is used for the build definition. Simply add the line:

testOptions in Test := Nil

For Play 2.0 or 2.1, project/Build.scala is used. You'll have to do something like the following:

val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
  // other project settings here
  testOptions in Test := Nil

Also, don't forget to add ScalaTest as a project dependency. At the time of writing, the latest version can be specified with the following:

"org.scalatest" % "scalatest_2.10" % "2.0" % "test"
Recent Posts

Let's talk.

Give Us a Call
(800) 352-2292
Business Inquiries