我似乎想不出如何把这三者结合起来。我发现了如何使用specs2和scalacheck进行测试,如下所示:
class ExampleSpec extends Specification with ScalaCheck { def is = s2"""
Example
scalacheck $e1
"""
def e1 = prop((i: Int) => i == i)
}使用所谓的 style。
然而,在Play中, style必须使用WithApplication之类的好东西。
我天真地认为这会奏效:
class PlayExampleSpec extends PlaySpecification with ScalaCheck {
"Play" in new WithApplication() {
"scalacheck" in prop((s: String) => s == s)
}
}这个测试根本没有执行。我已经浏览了一半的互联网,但都没有结果。请帮帮忙。
发布于 2015-10-12 22:43:04
如果您正在使用WithApplication,您需要能够在属性失败时抛出异常(因为prop是纯的,并且会丢失在WithApplication的主体中)。AsResult为您做了以下工作:
import org.specs2.execute.AsResult
class TestMutableSpec extends mutable.Specification with ScalaCheck {
"Example" in new WithApplication {
AsResult {
prop((s: String) => s != s)
}
}
}上面的例子应该失败。
https://stackoverflow.com/questions/33079701
复制相似问题