property-based-testing

Writes, reviews, and debugs property-based tests across Hypothesis, fast-check, proptest, and Echidna.

Updated Jun 15, 2026
One-click install
npx skills add https://github.com/ravenslight2010/Production-run-calculator --skill property-based-testing-ravenslight2010
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: property-based-testing
Source: https://github.com/ravenslight2010/Production-run-calculator/tree/main/.agents/skills/property-based-testing
Command: npx skills add https://github.com/ravenslight2010/Production-run-calculator --skill property-based-testing-ravenslight2010

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Example-based tests only check hand-picked inputs, leaving most of the input domain untested and edge-case bugs undiscovered. This Skill helps you assert rules over entire input domains so generators hunt for counterexamples, and it helps you tell genuine bugs from wrong properties when a shrunk counterexample appears. ## Core Features & Use Cases - Property design and generation: Choose the strongest applicable property (roundtrip, inverse, oracle, idempotence, invariant, commutativity) and build strategies that generate valid inputs directly instead of over-filtering with assume(). - Test review and failure triage: Detect tautological, vacuous, and reimplementing assertions in existing suites, and classify shrunk failures as code bugs, wrong properties, or ambiguous specs. - Refactoring for testability: Extract pure cores, add inverse functions, and inject dependencies to expose assertable properties in code that mixes I/O with calculation. - Use Case: When adding tests for a serializer, use this Skill to write a Hypothesis roundtrip property decode(encode(x)) == x with pinned edge-case examples, then interpret any shrunk failure against the documented contract. ## Quick Start Ask the assistant to write property-based tests for your serialization or validation module using the property-based-testing skill.

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 with Hypothesis in Python?

Use the @given decorator with strategies like st.integers() or st.lists() to generate inputs, then assert an algebraic property such as a roundtrip or invariant. Put constraints in the strategy itself rather than assume(), and pin known edge cases with @example.

What properties should I test for serialization code?

The strongest property is the roundtrip: decode(encode(x)) == x. If no decoder exists, fall back to invariants or determinism checks, since asserting only 'no crash' rarely justifies adding a PBT dependency.

fast-check vs Hypothesis vs proptest, which PBT library should I use?

Match the project's language and existing choice: Hypothesis for Python, fast-check for TypeScript/JavaScript, proptest for Rust, rapid for Go, and jqwik for Java. Introducing a second PBT library into a codebase that already has one is not worth it.

Why does my Hypothesis test pass but assert nothing?

The two common causes are tautology, where the assertion restates the implementation, and vacuity, where assume() filters out nearly every generated input. Push constraints into the strategy so the generator produces valid inputs directly.

How do I test Solidity smart contract invariants with Echidna?

Write echidna_ functions that are view/pure, take no arguments, and return a bool that must never become false, such as totalSupply matching a tracked sum. Use assertion mode with assert() inside callable functions for operation-specific properties.

When should I not use property-based testing?

Avoid it for code with no algebraic shape where the only assertable property is 'no crash', and for coverage-guided binary fuzzing, mutation testing, static analysis, or end-to-end UI tests, which need different tools.