Testing Beyond Examples: Property Based Testing with Hypothesis
summary
Introduces concrete use of Hypothesis: property rules instead of examples, defaulting to 100 generated cases and able to run 10,000+ deep CI runs; shows real fixes (split-bill off-by-one cents, cart negative total) found by state-machine and round‑trip tests, shrinking to minimal failing sequences, reproducible seeds and a failure database. Covers useful properties (roundtrip, invariants, fast‑path equivalence), strategy composition and pitfalls (don’t reimplement the function in the test, avoid overusing assume), and how to incrementally add Hypothesis to pytest.
AI-written summary · about
chapters (14)
- 0:00Property based testing intro
- 1:57What PBT solves
- 3:00Finding edge cases
- 4:23Where PBT shines
- 6:31Reproducibility and shrinking
- 7:32Built-in input strategies
- 9:59First Hypothesis test
- 12:03Split bill function example
- 13:51State machine testing
- 16:59Good property traits
- 19:05Common patterns for property based tests
- 20:29PBT mistakes to avoid
- 22:38Start using Hypothesis
- 23:41Q&A
related talks
27mHypothesis: Simpler Powerful Test Cases
41mProperty Based Testing in Python with Hypothesis
01h 31mIntroduction to Property-Based Testing
50mProperty based testing with Hypothesis
01h 24mIntroduction to Property Based Testing
26mProperty Based Testing the Python Way
01h 23mIntroduction to Property-Based Testing
41mProperty Based Testing with Hypothesis: Stronger Tests, Less Work
