Writing Properties
Explore writing properties in property-based testing by understanding valid input shapes and using stream_data generators. This lesson guides you through creating property tests in Elixir, focusing on generating inputs and verifying code properties across many cases to ensure reliability.
We'll cover the following...
As we saw in our initial examples, part of property-based testing is generating data and the other part is coming up with properties. In this and the next lessons, we’re going to focus on the latter.
Shape of inputs
The first thing to do when coming up with properties is to figure out the shape of valid inputs that our code works with.
“Shape“ is not a technical term or a definition: we’re using it to describe the space of possible values that the input can be, such as all strings or all lists of integers.
Figuring out the shape of valid inputs is where generators come into play in the context of property-based testing. If our code works with lists of integers, and therefore the shape of valid inputs is ...