Scala SBT不';t调用测试。在Play2项目上设置

Scala SBT不';t调用测试。在Play2项目上设置,scala,playframework,sbt,Scala,Playframework,Sbt,以下是我的SBT构建: val main = play.Project(appName, appVersion, appDependencies).settings(defaultScalaSettings:_*) .settings( scalaVersion := "2.10.0", resolvers += ..... ) .configs(IntegrationTest) .settings( Defaults.itSettings : _

以下是我的SBT构建:

  val main = play.Project(appName, appVersion, appDependencies).settings(defaultScalaSettings:_*)
    .settings(
    scalaVersion := "2.10.0",
    resolvers += .....
  )
    .configs(IntegrationTest)
    .settings( Defaults.itSettings : _*)
    .settings(
    testOptions in Test += Tests.Setup( () => println("Setup Test yoohooo") ),
    testOptions in Test += Tests.Cleanup( () => println("Cleanup Test yoohoo") ),
    scalaSource in Test <<= baseDirectory / "test/unit",
    parallelExecution in Test := true,

    testOptions in IntegrationTest += Tests.Setup( () => println("Setup Integration Test yoohoo") ),
    testOptions in IntegrationTest += Tests.Cleanup( () => println("Cleanup Integration Test yoohoo") ),
    scalaSource in IntegrationTest <<= baseDirectory / "test/integration",
    parallelExecution in IntegrationTest := false

  )
我的构建不应该覆盖这些设置吗


顺便问一下,我可以在此设置中调用外部库或测试源类吗?

可能这是sbt的约束

sbt官方文件称

分叉组时不支持设置和清理操作

fork-in测试:=true 是Play2.1.0中的默认值


“顺便问一下,我可以在此设置中调用外部库或测试源类吗?”。是的,但是您必须反射地调用它,因为在编译构建定义时它不会在类路径上。这似乎有点痛苦。即使是调用外部库,这个限制在sbt 0.13.0中也被取消了。
testOptions in Test += Tests.Setup { loader =>
  loader.loadClass("play.api.Logger").getMethod("init", classOf[java.io.File]).invoke(null, new java.io.File("."))
},

testOptions in Test += Tests.Cleanup { loader =>
  loader.loadClass("play.api.Logger").getMethod("shutdown").invoke(null)
},
fork in Test := true