DEV Community

Discussion on: From 1 to 10,000 test cases in under an hour: A beginner's guide to property-based testing

Collapse
 
drcat7 profile image
Cat

I had not heard of property-based testing before this, no.
Interestingly, the usage of post-conditions reminds me of a computer science class I had about formal program proofs. We used Frama-C for C and JML for Java and one of the exercises was about proving that a given sorting function is correct. Doing so involved writing the same post-conditions as this article.

As for the names, I think they're relative to how long it would take to write 100,000 tests by hand, yes. It's not wrong... But it's also not saying much 😂

Thread Thread
 
fornwall profile image
Fredrik Fornwall

Thanks for the discussion!

Regarding how design by contract (which at least JML is about) might relate to property-based testing I found a post which actually combines hypothesis (for property-based testing) with dpcontract (for design by contract):

Maybe they complement each other: “your code doesn’t violate any contracts” counts as a PBT invariant. Maybe we can generate inputs that match the preconditions and confirm that all of the postconditions (and preconditions of other called functions) are preserved.

I also like the following comment (from softwareengineering.stackexchange....

The relationship is that the combination of design by contract and the testing methods are attempting to substitute for a correctness proof, which would be the ultimate goal, if it were feasible.