use SizeRange instead
Use PropertyCheckConfiguration instead
Use PropertyCheckConfiguration directly instead.
This becomes more useful when we're dealing with our own data types.
This becomes more useful when we're dealing with our own data types. We'll use the case class defined in the Generators Section:
case class Foo(intValue: Int, charValue: Char)
Having an implicit def
or val
of our data type in the scope allow us to use the forAll
method without
specifying the generator
Let's see an example where we're defining an implicit
arbitrary
instance for Char
The Arbitrary.arbitrary
method also returns a Gen
object.
use maxDiscardedFactor instead
use SizeRange instead
The trap method is no longer needed for demos in the REPL, which now abreviates stack traces, and will be removed in a future version of ScalaTest
The
arbitrary
GeneratorThere is a special generator,
org.scalacheck.Arbitrary.arbitrary
, which generates arbitrary values of any supported type.The
arbitrary
generator is the generator used by ScalaCheck when it generates values for property parameters. Most of the times, you have to supply the type of the value toarbitrary
, like above, since Scala often can't infer the type automatically. You can usearbitrary
for any type that has an implicitArbitrary
instance. As mentioned earlier, ScalaCheck has default support for common types, but it is also possible to define your own implicitArbitrary
instances for unsupported types. See the following implicit Arbitrary definition for booleans, that comes from the ScalaCheck implementation.