A property check executes a Prop and returns an outcome describing whether its generated tests succeeded or failed. Returning information, rather than merely printing a report, preserves the data needed for composition. section 8.1.3
A useful check distinguishes several concerns:
- A Boolean can express success or failure, but loses failure details and test counts. section 8.1.3
- An Either-based result can preserve a failed case, the number of successful tests, or the number of tests completed. section 8.1.3
- A helper can supply maximum size, test count, and a random generator, returning a Result for further handling. section 8.2.2
Checking a maximum property
A generated-list property checks that every element is less than or equal to the list maximum. Running it can reveal that empty lists violate the unstated assumption, prompting a nonempty-list generator. section 8.2.2
Listing 8.5 A check helper function for Prop
extension (self: Prop)
def check(
maxSize: MaxSize = 100, #1
testCases: TestCases = 100,
rng: RNG = RNG.Simple(System.currentTimeMillis)
): Result =
self(maxSize, testCases, rng)
Use the check helper to inspect how execution parameters become an explicit Result-producing operation. section 8.2.2
