property-based-testing

Guides developers through property-based testing with property patterns, generators, and shrinking.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/rubrical-works/idpf-praxis-skills --skill property-based-testing-rubrical-works
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: property-based-testing
Source: https://github.com/rubrical-works/idpf-praxis-skills/tree/main/Skills/property-based-testing
Command: npx skills add https://github.com/rubrical-works/idpf-praxis-skills --skill property-based-testing-rubrical-works

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Example-based tests only cover the cases you think of, leaving edge cases and subtle bugs undiscovered. This Skill teaches property-based testing, where you define invariants that must hold for all inputs and the framework generates and shrinks test cases automatically. ## Core Features & Use Cases - Property Definition Patterns: Covers roundtrip, idempotence, commutativity, associativity, identity, invariant, and reference-comparison properties with concrete examples. - Generator and Shrinking Guidance: Explains built-in and custom generators, plus how shrinking reduces failing inputs to minimal counterexamples for faster debugging. - Framework-Specific Examples: Provides working code for Hypothesis (Python), fast-check (JavaScript), jqwik (Java), proptest (Rust), and gopter (Go). - Use Case: When testing a serialization function, define the property deserialize(serialize(x)) == x and let the framework discover edge cases like empty strings, unicode boundaries, or null fields that manual tests would miss. ## Quick Start Ask the AI to help you write property-based tests for a function using Hypothesis or fast-check, including property definitions and generator setup.

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 property-based tests in Python?▼

Use the Hypothesis library with the @given decorator and strategies like st.integers() or st.lists() to generate inputs. Define assertions about properties that must hold for all inputs, such as len(sorted(lst)) == len(lst), and Hypothesis generates and shrinks test cases automatically.

What is the difference between property-based testing and example-based testing?▼

Example-based testing checks specific hand-picked inputs like add(2, 3) == 5, while property-based testing asserts invariants like add(a, b) == add(b, a) for all generated inputs. Property tests discover edge cases automatically; example tests document known behavior and regressions.

What is shrinking in property-based testing?▼

Shrinking is the process where the framework reduces a failing input to the minimal case that still fails. For example, a failing 150-element list might shrink to [0, -1], making the root cause of the bug immediately visible.

Hypothesis vs fast-check for property-based testing?▼

Hypothesis is the standard choice for Python with excellent shrinking and stateful testing support. fast-check serves JavaScript and TypeScript projects with good performance, async property support, and model-based testing commands.

When should I not use property-based testing?▼

Avoid property-based testing for non-deterministic behavior, tests requiring specific known edge cases, or when generators would be too slow. Keep example-based tests for bug reproductions, documented behavior, and fast deterministic checks alongside property tests.

Why does my property test fail with a counterexample I don't understand?▼

Reproduce the failure manually using the exact minimal counterexample the framework reports, then trace execution with debug logging. Watch for boundary values like 0, empty collections, or integer limits, which often reveal missing null handling or overflow issues.