在使用Play 2.1.1中的WithApplication范围进行测试时,我遇到了一个有趣的问题。
这是我的代码:
import play.api.test.{FakeApplication, WithApplication}
import org.specs2.mutable.Specification
class TestSpec extends Specification {
"Test" should {
"fail" in {
true === false
}
"fail as well" in new WithApplication() {
true === false
}
"fail with extreme prejudice" in new WithApplication(FakeApplication()) {
true === false
}
}
}我预计这三种方法都会失败,但在这种情况下,只有第一种失败。
[info] Total for specification TestSpec
[info] Finished in 21 ms
[info] 3 examples, 1 failure, 0 error
[info]
[error] Failed: : Total 4, Failed 1, Errors 0, Passed 3, Skipped 0
[error] Failed tests:
[error] TestSpec有什么诡计我错过了吗?
我使用Scala2.10.2,SBT0.12.2,Play 2.1.1,在Java7 U40上运行。
提前谢谢。
发布于 2013-10-10 23:16:23
您应该尝试一个最新版本的Play或最新版本的specs2 (2.2.3),其中该问题已经修复。
https://stackoverflow.com/questions/19294983
复制相似问题