Introduction to Custom Generators
Explore the importance of custom generators in property-based testing with PropEr in Erlang. Understand how they help focus tests on specific edge cases and improve bug detection beyond random input generation. Learn methods for gathering test statistics and enhancing test reliability.
We'll cover the following...
Why use custom generators?
Until now, we have only used default generators in the properties that we have written. If we were to use these tools and techniques only, there is a chance that we could improve our tests by quite a bit. In the previous chapter, we saw how to test an encoder and a decoder with symmetric properties. Say we suspected there was a bug whenever there are more than 255 elements in a map. 255 is a number that could hit the upper limits of what a byte can store.
To put it in other terms, the properties we’ve written so far have relied on fairly random generated data to act as inputs. The theory is that with enough random walks, we can eventually get into every nook and cranny of the code and find all the edge cases. But there’s no guarantee ...