[英]SBT doesn't call Test.Setup on a Play2 project
Here is my SBT build: 这是我的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
)
I can launch both tasks test
and it:test
, but it only prints the text for the IntegrationTest, and not for the regular Test. 我可以同时启动任务
test
和it:test
,但是它只打印IntegrationTest的文本,而不是常规Test的文本。
I see that Play2 has some default settings related: 我发现Play2具有一些相关的默认设置:
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)
},
Isn't my build supposed to override these settings? 我的构建不应该覆盖这些设置吗?
By the way, can I call an external library or a test source class in this Setup? 顺便说一句,我可以在此安装程序中调用外部库或测试源类吗?
Maybe this is constraint of sbt. 也许这是sbt的约束。
sbt official documents says sbt官方文件说
Setup and Cleanup actions are not supported when a group is forked.
分组时不支持“设置”和“清除”操作。
https://github.com/sbt/sbt/blob/v0.12.2/src/sphinx/Detailed-Topics/Testing.rst#forking-tests https://github.com/sbt/sbt/blob/v0.12.2/src/sphinx/Detailed-Topics/Testing.rst#forking-tests
http://www.scala-sbt.org/0.12.2/docs/Detailed-Topics/Testing.html http://www.scala-sbt.org/0.12.2/docs/Detailed-Topics/Testing.html
fork in Test := true
is default from Play2.1.0 是Play2.1.0的默认设置
https://github.com/playframework/Play20/pull/654/files#L5L110 https://github.com/playframework/Play20/pull/654/files#L5L110
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.