Definition

Test data generator

What does a generator do in a property test?

A test data generator describes how to produce inputs for a property test. Its choices determine which shapes, ranges and combinations the property can encounter. Generators can deliberately produce valid inputs, invalid inputs or both, depending on the behaviour being checked.

How can you tell which cases the generator exercises?

Inspect samples and count the categories that actually reach the assertion. Discarding most draws can hide a poor fit between the generator and the rule. Build valid structures from their parts and choose important boundaries explicitly so unusual cases receive enough attention.

Worked example

Generating appointments that cross a date boundary

For a valid appointment interval, generate a start time and a positive duration, then derive its end time. Include starts just before midnight. Use a separate set of reversed intervals to check the validation message for an end time before the start.

Try it on your pull request

Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.

Try Cue April on your repository