在playframework项目中使用scalatest

Fra*_*awr 5 sbt scalatest playframework

我正在scala中的一个playframework项目.但是我们的团队想要使用scalatest而不是specs.我已将以下内容添加到plugins.sbt文件中:

libraryDependencies += "org.scalatest" %% "scalatest" % "1.7.1" "test"
Run Code Online (Sandbox Code Playgroud)

但是当我开始游戏时,没有新的罐子被下载,甚至在运行之后也没有

update
Run Code Online (Sandbox Code Playgroud)

当我跑

library-dependencies
Run Code Online (Sandbox Code Playgroud)

它告诉我这个

[info] List(org.scala-lang:scala-library:2.9.1, play:play:2.0, play:play-test:2.0:test)
Run Code Online (Sandbox Code Playgroud)

此外,当我尝试测试时,我得到一个编译错误,说org.scalatest不在buildpath中.有谁知道出了什么问题?

Che*_*eng 7

你应该修改project/Build.scala,最好使用如下: -

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

请使用版本1.7.2,其中包含SBT集成中的错误修复.

此外,您需要将testOptions设置为Nil: -

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

这是因为Play 2.0默认会发送以下Specs 2测试选项,其中包括: -

顺序真正的junitxml控制台

ScalaTest无法识别它们,因此将testOptions设置为Nil应该可以修复它.