How property-based testing works in rapid
masterRapid operates by generating pseudo-random data based on a Generator specification.
- Specification: A
Generatordefines how data should be constructed but does not generate it immediately. - Drawing: When you call
.Draw(t, "name"), rapid consumes bytes from an internal random bitstream to construct the value. - Tracking: Rapid tracks how the random bytes correspond to the structure of the generated value. This metadata allows rapid to perform automatic minimization: when a test fails, rapid uses this structural knowledge to find the smallest possible input that still triggers the failure.
This differs from traditional example-based testing by checking high-level properties (e.g., decode(encode(x)) == x) against a diverse set of inputs rather than a fixed set of manual examples.