Generator-Driven Property Checking with ScalaCheck
Explore how to use ScalaCheck with ScalaTest through the ScalaCheckPropertyChecks trait to write generator-driven property tests. Understand how to apply conditions with whenever and manage shrinking to maintain test clarity and effectiveness.
We'll cover the following...
We'll cover the following...
In this lesson, we’ll take a look at the integration of ScalaCheck and ScalaTest to see how we can use ScalaCheck generators in a ScalaTest test suite. As usual, the first thing is to import the ScalaCheck integration.
The ScalaCheckPropertyChecks trait
The first thing we do is mix in the ScalaCheckPropertyChecks trait. It contains a number of methods called forAll to check our properties, as well as a method named whenever to evaluate a ...