Modeling
Explore the concept of modeling in property based testing to create clear, simple implementations that verify complex functions. Understand how to use models to validate code correctness, enhance test reliability, and apply these principles to stateful systems and oracles.
We'll cover the following...
What is modeling?
Modeling essentially requires us to write a simple implementation of our code, even if it is algorithmically inefficient. The model should be so simple that it is obviously correct. We can then optimize the real system as much as we want. As long as both implementations behave the same way, the complex and the obviously correct implementation should work equally as well. The complex implementation, however, probably also works faster. So, for code that does a conceptually simple thing, modeling is useful.
Example
For our example let’s look at the function that we created in the previous chapter, the biggest/1 function which returns the largest value in a ...