Property-Based Tests with test.check

Example-based tests rely on developers to enumerate enough examples to fully verify the behavior of the functions under test. Each additional example covers one more input and verifies its output. Property-based tests instead encourage you to look for properties of your functions that are always true. You can then use generators to produce a large number of random examples that can be fed into your code. For each generated example you can verify that the property holds true.

Property-based tests generally involve more time invested in assembling data generators and thinking carefully about the properties of our code. However, once we’ve created the generators and properties, we can produce an arbitrary number ...

Get Clojure Applied now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.