property-based-testing

Installation
SKILL.md

Property-Based Testing (PBT)

Instead of asserting f(3) == 9, assert a property that must hold for all inputs; the framework generates hundreds of cases, then shrinks any failure to a minimal counter-example.

Find properties (the hard part) — 7 patterns

  1. Round-trip: decode(encode(x)) == x (serializers, parsers, compress, crypto).
  2. Invariant: len(sort(xs)) == len(xs), output is ordered, total money conserved.
  3. Idempotence: f(f(x)) == f(x) (normalize, dedupe, PUT).
  4. Oracle: compare with a slow/simple reference implementation.
  5. Metamorphic: search(q + filter) ⊆ search(q); price(2×qty) == 2×price(qty).
  6. Commutativity/associativity where the domain promises it.
  7. No-crash / postcondition: for any valid input, no exception and result satisfies the contract.
Installs
3
GitHub Stars
4
First Seen
Oct 24, 2026