Definition

Shrinking

What is shrinking in property-based testing?

Shrinking is the search for a simpler input that still makes a property fail. A property-testing tool tries smaller values or shorter sequences and retains simplifications that reproduce the failure. The resulting counterexample gives a developer a concrete case to investigate and replay.

What makes a shrunk example worth keeping?

The example should still belong to the intended input domain and expose the same broken rule. Save its actual values alongside the property, tool version and available replay details. The smallest example a tool happens to find depends on its shrink strategy and search budget.

Worked example

Two items reveal a sorting fault

A generated list of ninety products loses a row after sorting. Shrinking removes unrelated rows until two products with the same displayed name and different IDs remain. Keeping those two rows makes the expected outcome easy to inspect. Both IDs should survive the sort.

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