How to specify it! A guide to writing properties of pure functions
summary
Five concrete strategies for pure functions: test invariants on generated trees, write postconditions for each operation, use metamorphic testing (change inputs and assert relations), build an abstract model and check results via model-based properties, and validate generators and shrinking. The author plants eight bugs: model-based tests find all bugs and are fastest (around six to eight tests on average), metamorphic tests are the best second choice, postconditions are middling, and simple invariant checks miss many faults.
AI-written summary · about
chapters (18)
- 0:00Intro
- 1:07Imagine testing reverse...
- 3:16Replicating the code in the tests...
- 8:11Property Based Testing
- 9:24Example
- 10:43Generator and shrinker
- 11:38Is there an invariant?
- 13:12Invariant properties
- 14:24insert
- 16:01Testing our tests
- 19:05Fixing shrinking
- 19:44What is the postcondition?
- 21:27What is the postcondition of find?
- 23:41Metamorphic properties
- 28:16Equivalence for trees
- 29:16Model-based properties
- 33:49Effectiveness
- 37:29Mean time to failure
related talks
42mInvariants are everything
01h 24mIntroduction to Property Based Testing
26mSome Problems with Properties: A Study on Property-Based Testing in Industry
23mProperty based testing is a mindset
36mProperty-Based Testing: Unveiling the Truth on Test Reduction
26mThe missing piece of testing
14mVerify, but test: extracting property-based tests from F* specifications
55mMuch ado about testing
