Basic Custom Generators

Once you discover that your data generation needs to be retargeted to better explore a problem space, plenty of constructs are available. We’ve seen how to use oneof(Generators) to impact our ability to get a more specific result set, but other more flexible tools exist to get even more control. In this section, we’ll see the basic building blocks of writing custom generators.

Those building blocks are controlling the size and amount of generated data, applying transformation to the generators themselves, restricting and filtering out some data from your generators, and finally, playing with probabilities when none of the previous approaches work.

Resizing Generators

The first and simplest thing to do with generators is ...

Get Property-Based Testing with PropEr, Erlang, and Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.