QlarifyLabs
← AI in Testing
Deciding what to testExperimental

Finding properties for property-based tests

Ask the model to propose general properties a piece of code should satisfy for all inputs — round trips, invariants, equivalences — so a property-based testing tool can check them with generated data.

How it works

Property-based testing replaces hand-picked examples with rules that should hold for any input, and lets a tool generate hundreds of inputs to try to break them. The hard part is thinking of the properties. Given a function, its documentation and its existing example tests, the model proposes candidates: encode-then-decode returns the original, sorting is idempotent, a total equals the sum of its parts, a result never exceeds a stated limit, an optimised implementation agrees with a simple one. It can also draft the generator for the input type and the test itself in the team's framework. Properties the tool falsifies are then examined: either a real bug, or a property that was never true.

A functiondocs, example testsModel proposesproperties, generator, testfor exampledecode(encode(x)) = xsort(sort(x)) = sort(x)total = sum of partsTool generates inputstries to break each oneFalsifiedsomeone examines whyA real bugNever trueIf it holds, the pass is only as goodas the generator behind it.
The model suggests the rules; the tool tries to break them. A broken rule is either a bug or a rule that was never true.

When to use it

Parsers, serialisers, calculations, data transformations and anything with a clear mathematical shape; code with good example tests but suspected edge-case bugs; and teams that want to try property-based testing but don't know where to start.

Limitations

Many proposed properties are either trivially true or subtly false, and a false property produces failures that look like bugs until someone works out the property was wrong. The model favours textbook properties and is weaker at the domain-specific ones that catch real defects. Generators it writes can be too narrow to explore the space, which makes a passing run mean less than it appears to.

Watch for

A property passes every run because the generator only makes short plain-text strings, so no emoji, accents or empty input ever reach the parser. Have the tool report what kinds of input it generated, and check the awkward cases actually appear.

What you still own

Deciding which properties are genuinely required behaviour, and judging whether each failure is a bug in the code or in the property.

Related evals

Cite this

Qlarify Labs. (2026). Finding properties for property-based tests. Retrieved from https://labs.qlarify.fi/ai-in-testing/finding-properties-for-property-based-tests