tdd-property-testing
Installation
SKILL.md
Property-Based Testing
Instead of writing individual test cases with fixed inputs, you define properties (invariants) that should always be true for any valid input.
How it Works
- Define a strategy for generating random data (e.g., "any list of integers").
- Define a property (e.g., "sorting a list doesn't change its length").
- The framework generates hundreds of inputs to find a counter-example.
- If it finds one, it shrinks the input to the simplest possible case that fails.
Tools
- Python: Hypothesis
- JavaScript: fast-check
- Rust: proptest
Example (Python with Hypothesis)
from hypothesis import given, strategies as st