Generation Size
Explore how generation size influences the complexity of generated data in property-based testing with Elixir's StreamData. Understand how integers and other data types vary in size and complexity, learn the role of generation size in controlling outputs, and discover techniques like StreamData.resize to manage test data complexity effectively.
Getting to know generator size
If we take a few elements out of a generator like StreamData.integer/0, we’ll notice that those integers are simple, that is, they are small integers centered around zero. Now, try to take a few elements out of integer/0 but after discarding a lot of elements:
Executable
Output
iex> StreamData.integer() |> Stream.drop(100) |> Enum.take(5)
[43, -96, 45, -17, 40]
As we can see, the integers produced by the generator are now more complex—as in, they’re bigger. This suggests that generators produce increasingly more complex terms the more terms they generate. In the case of streaming terms out of a generator, that’s exactly what happens. However, the mechanism behind this is ...