property-based-testing

Generates property-based tests with shrinking and pinned counterexamples for invariant-rich code.

1|Updated Jul 3, 2026
One-click install
npx skills add https://github.com/Nandansai08/skillz --skill property-based-testing-nandansai08
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: property-based-testing
Source: https://github.com/Nandansai08/skillz/tree/main/skills/testing-qa/property-based-testing
Command: npx skills add https://github.com/Nandansai08/skillz --skill property-based-testing-nandansai08

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Example-based tests only cover the inputs you thought to write, so parsers, serializers, and math code ship with bugs hiding in null bytes, huge integers, and empty keys. This Skill guides you through writing generative property tests that explore thousands of inputs against a stated invariant. ## Core Features & Use Cases - Property catalog: Choose from five proven patterns — round-trip, oracle, invariant, idempotence/algebra, and metamorphic — instead of improvising weak assertions. - Generator design and reach checks: Build strategies that actually produce boundary, empty, and huge values, verified with library statistics rather than assumed. - Shrinking and pinning: Turn minimized counterexamples into permanent regression tests, with seed and failure-database handling so CI failures reproduce locally. - Use Case: A JSON config parser passes 30 example tests but crashes in production on a null byte; one round-trip property with a nested-structure generator finds four bugs in the first 200 generated cases. ## Quick Start Write a property-based test for my serializer using hypothesis that checks parse(render(x)) == x and pins any counterexample it finds.

Frequently Asked Questions about property-based-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a property-based test in Python with hypothesis?▼

Define a strategy with hypothesis st module that generates valid inputs, then assert a universal property such as decode(encode(x)) == x inside a @given-decorated test. Constrain inputs in the strategy itself rather than filtering with assume, and pin any failure with @example.

What properties should I test with property-based testing?▼

Choose from five standard patterns: round-trip for serializers, oracle comparing a fast implementation against a naive one, invariants like sortedness or non-negative balances, idempotence or algebraic laws, and metamorphic relations between related inputs.

When should I not use property-based testing?▼

Skip property-based testing when the contract is a handful of business rules, since example tests are clearer and sufficient there. It pays off only when the input space is large and you can state an invariant in one sentence.

Why does my property-based test fail in CI but not locally?▼

This happens when no seed or failure database is committed, so the random generation differs between runs. Store the hypothesis database or a fixed seed in the repository, and pin every discovered counterexample as an explicit example test.

Why does hypothesis keep rejecting my generated inputs with assume?▼

Heavy assume usage means the generator is wrong: rejecting most of the space tests almost nothing while reporting success. Rewrite the strategy to construct only valid values directly, reserving assume for rare cross-parameter constraints.