Property-Based Testing

Noun · Development

Definitions

  1. A testing approach where you define properties that should always hold true (invariants), and the framework generates hundreds of random inputs to try to find a counterexample. When it finds a failure, it shrinks the input to the minimal failing case. Finds edge cases humans wouldn't think of. Libraries: Hypothesis (Python), fast-check (JS), QuickCheck (Haskell).

    In plain English: Testing by describing what should always be true, then letting the computer generate random inputs to try to prove you wrong.

    Example: "The property test for sort says: for any list, sort(list) should have the same length and every element should be ≤ the next. fast-check found a bug with empty arrays."

Related Terms