typelevel / scalacheck-effect

Effectful property testing built on ScalaCheck
Apache License 2.0
82 stars 24 forks source link

Support customizing parameters on a per PropF basis #8

Open mpilquist opened 4 years ago

mpilquist commented 4 years ago

ScalaCheck supports this like so:

scala> val p = Prop.forAll { (x: Int, y: Int) => (x + y) == (y + x) }
val p: org.scalacheck.Prop = Prop

scala> val q = Prop(prm => p(prm.withInitialSeed(0L)))
val q: org.scalacheck.Prop = Prop

To support in PropF, we could add a method like mapParameters(f: Gen.Parameters => Gen.Parameters): PropF[F].

TonioGela commented 2 years ago

Hi @mpilquist! It seems you're supposing that there's a way to alter parameters on a per ScalaCheckEffectSuite basis, correct? As far as I see genParameters: Gen.Parameters in ScalaCheckEffectSuite is private so it can't be accessed or modified (in scalacheck-effect-munit 1.0.3).

mpilquist commented 2 years ago

Yeah, the idea is to override scalaCheckTestParameters from the super ScalaCheckSuite:

  protected def scalaCheckTestParameters = ScalaCheckTest.Parameters.default

FS2 does this here:


  override def scalaCheckTestParameters =
    super.scalaCheckTestParameters
      .withMinSuccessfulTests(if (isJVM) 25 else 5)
      .withWorkers(1)
TonioGela commented 2 years ago

Brilliant! Thanks and sorry for the off-topic.