Search⌘ K
AI Features

Default Generators

Learn about default generators provided by PropEr essential for property based testing in Erlang. Understand how these generators produce data like atoms, integers, lists, and tuples to automate input creation for your properties. This lesson helps you grasp their usage and importance in crafting effective tests.

We'll cover the following...

Generators

Generators are a huge part of where a property-based testing framework’s magic comes from. While developers 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 a useful framework, and great generators will directly impact how much trust you can put into our tests.

Generators are functions that contain a bunch of internal parameters that direct their randomness, how the data they create gets more or less complex, and information 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 since it lets us create all the kinds of Erlang data we might need. You’ll likely even want to use generators outside of a testing context because they are just that nifty.

Default generators

PropEr comes with quite a few basic data generators. They tend to represent all the relevant basic data types of the language ...