更新时间:2023-02-06 19:15:13
如果您使用的是纯ScalaCheck属性,则应该能够使用Test.Params
类更改所使用的java.util.Random
实例并提供您的自己的,总是返回相同的一组值:
If you're using pure ScalaCheck properties, you should be able to use the Test.Params
class to change the java.util.Random
instance which is used and provide your own which always return the same set of values:
def check(params: Test.Parameters, p: Prop): Test.Result
[已更新]
我刚刚发布了一个新的specs2-1.12.2-SNAPSHOT,您可以在其中使用以下语法来指定您的随机生成器:
I just published a new specs2-1.12.2-SNAPSHOT where you can use the following syntax to specify your random generator:
case class MyRandomGenerator() extends java.util.Random {
// implement a deterministic generator
}
"this is a specific property" ! prop { (a: Int, b: Int) =>
(a + b) must_== (b + a)
}.set(MyRandomGenerator(), minTestsOk -> 200, workers -> 3)