Transforming Generators
Explore how to transform data generators using PropEr's let macro to build complex and composable custom generators in Elixir. Understand how to generate advanced data structures like queues without exposing internal representations, enabling cleaner, more maintainable property-based tests.
We'll cover the following...
Why transform generators?
To understand why we may need to transform generators, let’s take a look at an example. Using the queue module, we may want to generate a first-in-first-out queue of key/value pairs. Just using tuples and lists won’t be enough to enforce the internal constraints of the data structure. In some cases, the data structure may be opaque which means that we can’t or shouldn’t look into how it’s built, and rather just stick to the interface the module exposes. This is inconvenient at best. To solve this problem, PropEr exposes macros that let us apply ...