scalacheck-effect icon indicating copy to clipboard operation
scalacheck-effect copied to clipboard

Add an Arbitrary[Random[F]] instance

Open bpholt opened this issue 1 year ago • 2 comments

This will link the randomness used by the code under test to ScalaCheck's seed, which should improve test repeatability.

I didn't see a good place to introduce this instance; previously users would have to use both scalacheck-effect-munit and munit-cats-effect to run IO-based property tests. This introduces a new artifact that depends on both ScalaCheck and Cats Effect in order to make the instance available.

bpholt avatar Jul 18 '24 16:07 bpholt

Perhaps, it would make sense to add generators/arbitraries for java.unit.Random and scala.unit.Random directly to the scalacheck library.

Personally I would appreciate such an addition, because it can come in handy for many non-effect driven property-based tests as well.

Then, having those arbitraries, obtaining a cats.effect.std.Random instance would become a pretty straightforward task and could be done in specific test code directly.

satorg avatar Jul 18 '24 18:07 satorg

Oh, that's an interesting idea! I'm not at a computer at the moment but I'll play with that when I get a chance and see how it works.

bpholt avatar Jul 18 '24 18:07 bpholt