Property-based testing seems much fancier than example-based testing. It also explores the input domain much better. Should we only use property-based testing from now on?
In practice, I mix example-based testing and property-based testing. In the testing workflow I propose, I use example-based testing when doing specification-based and structural testing. Example-based tests are naturally simpler than property-based tests, and they require less creativity to automate. I like that: their simplicity allows me to focus on understanding the requirements and engineer better test cases. When I am done with both testing techniques and have a much better grasp of the program under test, I evaluate which test cases would be better as property-based tests.
Do I always write property-based tests for my programs? Honestly, no. In many of the problems I work on, I feel pretty confident with example-based testing. I use property-based testing when I do not feel entirely secure that my example-based tests were enough.
Leave a Reply