First of all, awesome writeup and I’m glad PBT was useful to you!
Re your comment about reversing a list, @drmaciver has a great tweet on that:
Every time someone uses reversing a list twice to demonstrate property-based testing, I take a drink.
No, this isn’t a drinking game, I’m just being driven to drink by bad examples.
I agree with him. People have trouble seeing how to use PBT because all of the examples given are small trite toys! We need more stuff like what you wrote that shows it actually being useful in real production cases.
@owi also has some really good posts on this, if you want to read more. Check out his blog!
Yeah, the first time I encountered PBT it was in I believe the Appendix of an introductory clojure book years ago. Their example was was division and multiplying and yeah sure that makes sense but my examples are hardly ever so easy. I really like it as a property for serialization/deserializaion. That’s how jason does some of its testing.
@owi’s blog seems really good, I just took a sneak peek, but whenever people take the care to produce illustrative diagrams you know they care.
Currently I’m reading Fred Herbert’s PBT book to level up my skills in hopes of being able to effectively apply PBT a lot more.
PBT is for sure good at finding edge cases. I used it for some physics simulations and the number of times I shook my fist at the sky and angrily yelled “FLOATING POINT” is nonzero. Part of that was my own fault for not restricting the range of generated values though.
That’s what I think is so interesting: It makes you think in properties and what input data exactly does your function accept because it’s good at generating data that’s like “wait I’d never want my function to get this!” which I think is already good value in itself :)
First of all, awesome writeup and I’m glad PBT was useful to you!
Re your comment about reversing a list, @drmaciver has a great tweet on that:
I agree with him. People have trouble seeing how to use PBT because all of the examples given are small trite toys! We need more stuff like what you wrote that shows it actually being useful in real production cases.
@owi also has some really good posts on this, if you want to read more. Check out his blog!
Thanks for the nice words!
Yeah, the first time I encountered PBT it was in I believe the Appendix of an introductory clojure book years ago. Their example was was division and multiplying and yeah sure that makes sense but my examples are hardly ever so easy. I really like it as a property for serialization/deserializaion. That’s how jason does some of its testing.
@owi’s blog seems really good, I just took a sneak peek, but whenever people take the care to produce illustrative diagrams you know they care.
Currently I’m reading Fred Herbert’s PBT book to level up my skills in hopes of being able to effectively apply PBT a lot more.
PBT is for sure good at finding edge cases. I used it for some physics simulations and the number of times I shook my fist at the sky and angrily yelled “FLOATING POINT” is nonzero. Part of that was my own fault for not restricting the range of generated values though.
That’s what I think is so interesting: It makes you think in properties and what input data exactly does your function accept because it’s good at generating data that’s like “wait I’d never want my function to get this!” which I think is already good value in itself :)
Exactly! I think property based testing is a good teaching tool.