How are design-by-contract and property-based testing (QuickCheck) related?

Posted by Todd Owen on Programmers See other posts from Programmers or by Todd Owen
Published on 2013-06-29T01:47:48Z Indexed on 2013/06/29 4:27 UTC
Read the original article Hit count: 207

Filed under:
|
|

Is their only similarity the fact that they are not xUnit (or more precisely, not based on enumerating specific test cases), or is it deeper than that?

Property-based testing (using QuickCheck, ScalaCheck, etc) seem well-suited to a functional programming style where side-effects are avoided. On the other hand, Design by Contract (as implemented in Eiffel) is more suited to OOP languages: you can express post-conditions about the effects of methods, not just their return values.

But both of them involve testing assertions that are true in general (rather than assertions that should be true for a specific test case). And both can be tested using randomly generated inputs (with QuickCheck this is the only way, whereas with Eiffel I believe it is an optional feature of the AutoTest tool).

Is there an umbrella term to encompass both approaches? Or am I imagining a relationship that doesn't really exist.

© Programmers or respective owner

Related posts about testing

Related posts about design-by-contract