Introduction to Property-Based Testing
summary
Introduction teaches Hypothesis with concrete code, not just theory: it runs the @given decorator, uses st.integers().filter(lambda b: b != 0) and pytest integration, and demonstrates finding both the obvious ZeroDivisionError and a subtler floating point counterexample where assert a == b * result fails. It shows shrinking to minimal examples, how to build strategies for lists, strings and JSON, and practical tips for settings, databases and ghostwriting tests so you can reproduce and fix real bugs quickly.
AI-written summary · about
chapters (29)
- 0:00Introduction
- 2:43What is testing
- 13:50Summary
- 14:59Exercises
- 16:45Overview
- 18:24Scale
- 21:28Methods
- 22:58Map and Filter
- 24:05Just and sampled from
- 25:21One and nothing
- 26:45Build strategy
- 27:46Recursive
- 31:15Inferring strategies
- 33:40Special strategies
- 36:29Inner composite trick
- 37:57Data strategies
- 38:58Where to find them
- 43:37Recap
- 44:01Test Tactics
- 44:31Common Properties
- 46:42Round Trips
- 47:57Equivalent Functions
- 48:46Validate Output
- 49:57Local assertions
- 50:27Hypothesis
- 51:02Metamorphic Relations
- 53:09Metamorphic Functions
- 53:59Conclusion
- 54:25Live Demo
related talks
01h 31mIntroduction to Property-Based Testing
27mTesting Beyond Examples: Property Based Testing with Hypothesis
01h 24mIntroduction to Property Based Testing
27mHypothesis: Simpler Powerful Test Cases
26mProperty Based Testing the Python Way
41mProperty Based Testing in Python with Hypothesis
40mProperty-based Thinking
50mProperty based testing with Hypothesis
