Default Generators

Get introduced to generators and take a look at a few default generators provided by PropEr.

We'll cover the following

Generators

Generators are a huge part of where a property-based testing framework’s magic comes from. While we do the hard work of coming up with properties, the efficiency with which they will be exercised depends on what kind of inputs will be passed to them. A framework with inadequate generators is not an interesting framework, and great generators will directly impact how much trust we can put in our tests.

Generators are functions that contain a bunch of internal parameters that direct their randomness. The data they create gets more or less complex based on the information they contain about other generators that can be used as parameters. We don’t need to know how their internals work to use them. From our point of view, they’re just functions that can be combined. However, being familiar with what data they can generate is important as it lets us create all the kinds of data we might need. We’ll likely even want to use generators outside of a testing context because they are just that nifty.

Get hands-on with 1200+ tech skills courses.