
Finding Property Tests (2019) - gmcabrita
https://www.hillelwayne.com/post/contract-examples/
======
Noumenon72
> 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...](https://fsharpforfunandprofit.com/posts/property-based-testing-2/)
and
[https://www.hillelwayne.com/post/contracts/](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.

~~~
BFdes
I think it is a trade off between being accurate with language and engaging
the reader. If we were being accurate we would need to say that random
sampling is only necessary if the domain is infinitely sized or very large.

I had a this problem when writing a very similar blog post.

------
unhammer
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.

------
kqr
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.

