Wednesday, 06 March 2019

Property-based Testing in a nutshell.

Property-based Testing in a nutshell.

Hi! Welcome to part one of my series on mental models. Click here for other parts.

Let’s say we have ourselves a sorting function called mySort ,

Standardized testing would ask you to come up with some values to be tested,

whereas Property-based Testing asks you to declare the schema of the data,

Property-based Testing example (pseudo-code).

and the testing framework takes care of generating the test-data for you.

The actual code is quite similar. The only difference being that in a standardized test you provide values, whereas for property-based tests you provide arbitraries* (i.e. types), and test-data is generated for you.

Standardized testing has values as first-class citizens, whereas Property-based Testing has types in its stead*.