PhraseryPhrasery homeGet Phrasery
Tests & QA21 categories

Find property-based test ideas

Code with a large input space where example tests only scratch it.

Longproperty-basedideascoverage
Suggest property-based tests for the code below.

Look for properties of these kinds:
- Invariants that hold for all inputs: length, ordering, sign, membership, conservation of total.
- Round trips: encode then decode, serialise then parse, do then undo.
- Equivalence: this implementation agrees with a slower obvious one.
- Idempotence: applying twice equals applying once.
- Commutativity or associativity, where the operation claims it.
- Metamorphic relations: how the output must change when the input changes in a known way.

For each property: state it in plain language, then as test code, with a suitable generator. Note which inputs the generator must be able to produce for the property to be meaningful, and flag any property you suspect is false for this code.

Code:

Making it yours

  • Paste your own material where the prompt asks for it. Everything above that line is instruction, not content.
  • Delete any rule that does not apply to you. A shorter prompt that fits beats a thorough one that does not.
  • If the answer comes back vague, add a line saying what you do not want. Constraints work better than encouragement.

Finding coverage gaps. Working out which behaviours, edge cases and error paths nothing currently checks.

Related prompts

Keep this one

Phrasery saves prompts with a right-click and puts them back the same way. Add this to your own library in one click.

Add to your browser โ€” free