Property-Based Testing
ScalaCheck.
What is Property-Based Testing?
In property-based testing you state a general property that should hold for all inputs, and the framework generates many random inputs to try to falsify it. This finds edge cases hand-written examples miss.
Example vs Property
An example test checks one case: reverse(List(1,2,3)) == List(3,2,1). A property states a rule: reversing twice yields the original list, for any list. The framework checks that rule on hundreds of generated lists.
All lessons in this course
- ScalaTest Styles
- Matchers
- Property-Based Testing
- Mocking and Fixtures