Find Edge Cases with Property-Based Testing
8 steps · about 3 h 20 min · Intermediate
- Write a first generated test (guide, Hypothesis, 25 min)
Generate varied inputs from a strategy and let the framework search beyond hand-picked examples.
- Think in invariants (guide, Hypothesis, 30 min)
Replace a list of expected examples with a rule that should hold across an input space.
- Compose useful data strategies (reference, Hypothesis, 30 min)
Build structured values whose generated cases remain valid and relevant to the behavior.
- Constrain data without hiding bugs (guide, Hypothesis, 25 min)
Transform and filter generators carefully so difficult boundary cases still appear.
- Reproduce a discovered failure (reference, Hypothesis, 20 min)
Use the examples database and explicit examples to make a failure repeatable.
- Remove flaky assumptions (guide, Hypothesis, 25 min)
Control time, randomness and external state so generated tests remain deterministic.
- Tune test execution responsibly (reference, Hypothesis, 20 min)
Set deadlines, example counts and health checks based on evidence rather than silencing warnings.
- Keep the minimal regression (guide, Hypothesis, 25 min)
Translate the shrunk counterexample into a clear example test alongside the durable property.