property-based-testing

Generates and validates code behavior across multiple scenarios using property-based testing.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/hung-phan/system-skills --skill property-based-testing-hung-phan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: property-based-testing
Source: https://github.com/hung-phan/system-skills/tree/main/skills/system-review/references/code-design/property-based-testing
Command: npx skills add https://github.com/hung-phan/system-skills --skill property-based-testing-hung-phan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires hypothesis, fast-check, quickcheck, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Property-based testing addresses the limitations of traditional example-based testing by validating code with respect to invariants that should hold for all inputs in a domain.

Core Features & Use Cases

  • Identify Invariants: Automatically generates a vast range of inputs to verify invariants in code, like round-trip properties and idempotency.
  • Shrinking Failures: Localizes failures to the smallest, most readable counterexample for quick debugging.
  • Supports Multiple Languages: Includes tools for Python (Hypothesis), TypeScript (fast-check), Haskell (QuickCheck), and more.
  • Use Case: Use it in a parser or serializer to ensure round-trip property, or when optimizing a function that requires a reference model.

Quick Start

Use the 'property-based-testing' skill to generate and validate invariants for a Python function that performs arithmetic operations.

Frequently Asked Questions about property-based-testing

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

FAQPage Schema
What is property-based testing and how does it find edge cases?

Property-based testing validates code invariants by automatically generating a vast range of randomized inputs. It identifies unseen edge cases by verifying that properties hold across the input domain, then shrinks failures to the smallest counterexample for quick debugging.

How do I validate invariants in my code using randomized testing?

You can validate invariants by defining properties like round-trip consistency or idempotency, then letting randomized testing tools automatically generate and test inputs. This ensures your code maintains robustness across the entire input domain without extensive manual input testing.

Does property-based testing support Python and TypeScript environments?

Yes, property-based testing supports multiple programming languages. It includes specific in-built validation tools like Hypothesis for Python, fast-check for TypeScript, and QuickCheck for Haskell, enabling invariant validation across different development environments.

What's the best way to debug a failing property-based test?

The best way to debug a failing property-based test is utilizing the shrinking mechanism. When a test fails, the framework automatically localizes the failure to the smallest, most readable counterexample, allowing you to quickly identify and fix the underlying invariant violation.

When should I use property-based testing instead of example-based testing?

You should use property-based testing when example-based testing falls short, such as validating parsers or serializers for round-trip properties. It is ideal when optimizing functions that require a reference model or when you need to verify invariants across a broad input domain.

Are there limitations to randomized testing for deterministic input generation?

While randomized testing excels at finding unseen edge cases, it relies on deterministic input generation for reliable unit testing. It may require defining clear invariants and understanding the input domain to ensure generated data remains valid and meaningful for your specific code.