我想使用基于属性的测试和 scalacheck 来测试我的 scala 程序。我写 :
class MyProperties extends PropSpec with PropertyChecks {
property("My property") {
val myProperty: org.scalacheck.Prop = new MyProperty
// some code I need to set myProperty
myProperty.check
}
}
但这似乎是错误的,因为当我使用 ScalaTest 运行此类时,我进入了控制台:
Run starting. Expected test count is: 1
MyProperties:
! Falsified after 51 passed tests.
> ARG_0: myGeneratedArgument
- My property
Run completed in 1 second, 623 milliseconds.
Total number of tests run: 1
Suites: completed 1, aborted 0
Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
所以问题是:我的财产是伪造的,但测试通过了!?!有人看到我的代码有什么问题吗?
谢谢...
编辑:我试图调用 myProperty 而不是 myProperty.check,但这并没有好多少,因为这样,生成器似乎被忽略了(只启动了一个测试而不是一百个)。