<< All versions

Skill v1.0.1

currentAutomated scan100/100
sethdford/claude-skills/property-based-testing

1 files

──Details
PublishedNovember 4, 2026 at 03:24 PM
Content Hashsha256:94dc3c7434e15305...
Git SHA00bd9265f5a3
Bump Typepatch
Compare with v1.0.0
──Files
Files (1 file, 1.8 KB)
SKILL.md1.8 KBactive
SKILL.md · 45 lines · 1.8 KB

name: property-based-testing description: Generative testing with QuickCheck/Hypothesis; testing properties that should hold for all inputs. metadata: version: "1.0.1"


Property-Based Testing

Testing that properties hold for arbitrary inputs generated by the framework.

Context

You are designing property-based tests. Describe a property (invariant) and let the framework generate hundreds of test cases.

Domain Context

  • Properties: "Sorting returns elements in ascending order" (invariant)
  • Generators: Framework generates random valid inputs
  • Shrinking: When a property fails, framework finds minimal failing case
  • Coverage: Catches edge cases humans wouldn't think of
  • Complementary: Use with unit tests, not replacement

Instructions

  1. Identify Invariants: What property must always be true? Idempotence? Commutativity?
  2. Choose Generators: What valid inputs should be tested? Numbers, strings, lists?
  3. Write Property: Assert the invariant; let framework vary inputs
  4. Run Generator: Property-based test runner generates cases, looks for failures
  5. Shrink Failures: When property fails, framework finds minimal case
  6. Document Examples: Add unit tests for important examples alongside property tests

Anti-Patterns

  • Testing trivial properties (identity, basic I/O); waste of PBT
  • Generators that are too narrow; should cover wide range of inputs
  • Ignoring shrunk failures; use them to understand the bug
  • Combining PBT with side effects; test pure functions
  • No complementary unit tests; properties are great but unit tests provide examples

Further Reading

  • John Hughes, _QuickCheck: A Lightweight Tool for Random Testing of Haskell Programs_
  • Hypothesis documentation (Python library for PBT)
← v1.0.0All versions