Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using scalatest in a playframework project

Im working on a playframework project in scala. Our team however wants to use scalatest instead of specs. I've added the following to the plugins.sbt file:

libraryDependencies += "org.scalatest" %% "scalatest" % "1.7.1" "test"

But when I start play, no new jars are being downloaded, not even after running

update

and when i run

library-dependencies

it shows me this

[info] List(org.scala-lang:scala-library:2.9.1, play:play:2.0, play:play-test:2.0:test)

Also when I try to test I get a compile error saying that org.scalatest is not in the buildpath. Does anyone know what is going wrong?

like image 804
Ferdy Avatar asked Apr 28 '12 09:04

Ferdy


2 Answers

You should modify project/Build.scala, and better to use like the following:-

val appDependencies = Seq(
  // Add your project dependencies here,
    "org.scalatest" %% "scalatest" % "1.7.2" % "test"
)

Please use the version 1.7.2, which contains a bug fix in SBT integration.

Also, you'll need to set the testOptions to Nil:-

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

This is because Play 2.0 by default will send the following Specs 2 test options in, which are:-

sequential true junitxml console

They are not recognized by ScalaTest, so setting testOptions to Nil should fix it.

like image 85
Chee Seng Avatar answered Oct 02 '22 22:10

Chee Seng


You should modify project/Build.scala, make the following change

val appDependencies = Seq(
  // Add your project dependencies here,
    "org.scalatest" % "scalatest_2.9.1" % "1.7.1"
)
like image 37
Qiang Jin Avatar answered Oct 03 '22 00:10

Qiang Jin