Reputation: 457
Using scalacheck, one can define some Properties as such:
object MyProps extends Properties("MyProps") {
property("myProp1") = forAll { (n:Int, m:Int) =>
n+m == m+n
}
property("myProp2") = forAll { ... }
property("myProp3") = forAll { ... }
}
I would like to override the default minimum number of successful tests (minSuccessfulTests) for just one single property, for example just for "myProp2"
.
Is there a way to do this?
Upvotes: 1
Views: 246
Reputation: 16095
Instead of PropFromFun
you can try implicitly converting to your own Prop
implementation:
class PropWithParameters(prop: Prop, params: Test.Parameters) extends Prop {
def apply(prms: Gen.Parameters) = prop(prms)
def check(): Unit = {
// Call super.check with params.
}
def withParams(moreParams: Test.Parameters): PropWithParameters = {
// return a new instance with params merged with moreParams.
}
}
object PropWithParameters {
implicit def convert(input: Prop): PropWithParameters = {
// Initialize with empty params here.
// I'm not sure if implicits get aligned easily
// in case of a subclass.
}
}
Then you can do something like:
object MyProps extends Properties("MyProps") {
property("myProp1") = forAll { (n:Int, m:Int) =>
n+m == m+n
}
property("myProp2") = forAll { ... } withParams(customParams)
property("myProp3") = forAll { ... }
}
Upvotes: 0