scalacheck icon indicating copy to clipboard operation
scalacheck copied to clipboard

Make test parameters configurable per property

Open rickynils opened this issue 11 years ago • 3 comments

It would be useful to set certain test parameters (RNG, minSuccessfulTests etc) for individual properties.

rickynils avatar Nov 27 '14 15:11 rickynils

+1

jazmit avatar Dec 28 '14 18:12 jazmit

+1

jarandaf avatar Mar 10 '16 11:03 jarandaf

+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
    }
...
}

howard-wang-nl avatar Mar 31 '16 09:03 howard-wang-nl