scalacheck
scalacheck copied to clipboard
Make test parameters configurable per property
It would be useful to set certain test parameters (RNG, minSuccessfulTests etc) for individual properties.
+1
+1
+1
I've tried to override the mainRunner of Properties class, but the parameters are not changed as expected. What's the correct way to achieve this?
import org.scalacheck.Prop.forAll
import org.scalacheck.Test
import org.scalacheck.{Gen, Properties}
import org.scalatest.Matchers
class CoordinateTruncProp extends Properties("CoordinateTruncProperties") with Matchers {
override def mainRunner(args: Array[String]): Int = {
val res = Test.checkProperties(Test.Parameters.default.withMinSize(200).withMaxSize(1000).withMinSuccessfulTests(200), this)
val failed = res.filter(!_._2.passed).size
failed
}
property("CoordinateTrunc") =
forAll(Gen.choose(-400.0, 400.0)) { (coord) =>
coord - truncateDoubles.truncate(coord) < 0.1
}
...
}