Browse Clojure Foundations for Java Developers

Property-Based Testing with test.check

Test invariants with generated inputs and shrinking—especially powerful for pure functions.

Property-based testing flips the usual approach:

  • Instead of writing a handful of example inputs, you describe an invariant (“property”) that should always hold.
  • A generator produces many random inputs to try to break it.
  • When a failure happens, the tool shrinks the input to a minimal counterexample you can reason about.

This style is especially effective for Clojure’s pure data transformations, where the behavior is easy to specify and hard to exhaustively cover with hand-picked examples.

In this section

Revised on Friday, April 24, 2026