| Class Summary | |
trait
|
CheckSuite
extends Suite
Trait that contains several “check” methods that can be used to perform ScalaCheck property checks
that will be reported as a ScalaTest test failure if ScalaCheck finds a test case for which the property doesn't hold.
To use ScalaCheck, you specify properties and, in some cases, generators that generate test data. You need not always
create generators because ScalaCheck provides many default generators for you, which can be used in many situations.
ScalaCheck will use the generators to generate test data and with that data run tests that check that the property holds.
Property-based tests can, therefore, give you a lot more testing for a lot less code than asertion-based tests.
Here's an example of using ScalaCheck from a ScalaTest suite:
import org.scalatest.scalacheck.CheckSuite
import org.scalacheck.Arbitrary._
import org.scalacheck.Prop._
class MySuite extends CheckSuite {
def testConcat() {
checkProperty(
(a: List[Int], b: List[Int]) => {
a.size + b.size == (a ::: b).size
}
)
}
}
|