Finding Property Tests (2019)

gmcabrita | 43 points

> A different testing style is property based testing (PBT) with contracts. By generating a random set of inputs, we cover more of the state space than we’d do manually.

For someone new to the way you define property and contracts, the second sentence is not enough definition. The article made sense once I found other links in the article defining property and contracts: https://fsharpforfunandprofit.com/posts/property-based-testi... and https://www.hillelwayne.com/post/contracts/.

I would summarize by saying

> A different testing style is property based testing (PBT) with contracts. By testing invariant properties like commutativity instead of specific cases, and writing the functions under test with assertion-like contracts that fail if they ever attempt invalid behavior, we can test with random input data and cover more of the search space than we would manually.

Noumenon72 | 4 years ago

Interesting, it's always useful to see strategies of coming up with property tests.

However, it kind of takes away the punch when both of the issues ("None" as an element in a list of numbers and 0 being falsy) would have have been eliminated by the type checker in a language like Haskell.

unhammer | 4 years ago

The concept of metamorphic testing sounds incredibly fruitful. I haven't immediately figured out how I can apply it to my domain, but I suspect it can elevate the testing we currently do to much more useful/meaningful levels.

kqr | 4 years ago