Migration From ScalaCheck
Migration From ScalaCheck#
For many cases migrating from ScalaCheck to Hedgehog should be fairly straight forward, as the general principals are quite similar, and the changes are largely syntactic.
Properties#
Some basic rules:
Replace
Properties("...")with justPropertiesReplace
Prop.forAllwith a call to forAll on a specificGeninstanceflatMapover the result of yourgenFoo.forAll, or use aforcomprehension.Return your
ProporBooleanassetions withResult.assert(...)Replace label or
:|with Result.log(...)Replace equality assertions like
?=with====
ScalaCheck#
Hedgehog#
Gen#
Some basic rules:
Gen.listandGen.listOfNcan be replaced with a call tolist(Range.linear(0, n))on a specificGeninstance.Gen.constis nowGen.constantArbitrary.arbitrary[Int]is nowGen.int(Range.linear(min, max))Gen.oneOfis nowGen.choice1
It's important to note that there are no more "default" Arbitrary instances
to summon. You must decided what kind of int or String you want to
generate, and what their Range is.
ScalaCheck#
Hedgehog#
Arbitrary#
Some basic rules:
- Replace
implict deffunctions that returnArbitraryto a function that returns theGendirectly.
ScalaCheck#
This example was taken from the ScalaCheck Guide.
Shrink#
This is assuming you're even writing them in the first place...
ScalaCheck#
Hedgehog#
Good news, you don't need to do anything! Just write your generators.