Resizing Generators
Understand the concept of resizing and how to use the resize function in properties.
We'll cover the following...
What is resizing?
Resizing is the process that makes generators grow bigger:
- Make an integer larger.
- Make a list longer.
- Make a string have larger codepoints.
This is the simplest thing to do with custom generators.
In fact, PropEr makes that happen for us on its own as the tests run. The way generator growth works is that PropEr internally uses a size parameter. Its value is usually small at first, but as tests run, the value is increased, and the data generated grows in complexity along with it. This allows the framework to start testing our systems with initially small data, and to then progressively make it more complex.
Resizing is part of a strategy to find easy edge conditions such as 0, empty containers, or strings, handling negative or positive numbers (which turn out to cover a large set of bugs) early on. Then, as each early test passes against these expected edge conditions, the framework grows the data it generates to find trickier bugs. The more tests pass in a run, the larger the ...