property-based-testing

Generate and review property-based tests across multiple languages and smart contracts.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill property-based-testing-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: property-based-testing
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/property-based-testing
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill property-based-testing-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Example-based tests often miss edge cases in serialization, parsing, validation, and normalization code. This Skill detects code patterns where property-based testing provides stronger coverage and guides the generation, review, and interpretation of property-based tests. ## Core Features & Use Cases - Pattern Detection: Recognizes encode/decode pairs, validators, normalizers, pure functions, and smart contract invariants that benefit from property-based testing. - Test Generation & Review: Produces tests with appropriate strategies, properties, and edge cases, and audits existing tests for tautologies, vacuous assumptions, and weak assertions. - Failure Analysis: Classifies failing property tests as genuine bugs, test bugs, or ambiguous specifications before reporting. - Use Case: When writing tests for a JSON serializer, the Skill suggests a roundtrip property (decode(encode(x)) == x) with Hypothesis, fast-check, proptest, or Echidna depending on the language. ## Quick Start Ask the AI to write property-based tests for your serialization or validation function using the appropriate library for your language.

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

Use the @given decorator with strategies from hypothesis.strategies to generate inputs, then assert algebraic properties like roundtrip or idempotence. Build constraints into the strategy itself rather than filtering with assume(), and add @example decorators for edge cases.

What properties should I test for encode and decode functions?

Serialization pairs should be tested with a roundtrip property: decode(encode(x)) == x. Also test that encoding is deterministic and produces the expected output type, and that decoding invalid bytes raises the documented exception.

Which property-based testing library should I use for my language?

Use Hypothesis for Python, fast-check for JavaScript/TypeScript, proptest for Rust, rapid for Go, jqwik for Java, and ScalaCheck for Scala. For Solidity smart contracts, use Echidna or Medusa fuzzers to test state invariants.

Why does my property-based test fail on edge cases?

Failures may be genuine bugs, test bugs, or ambiguous specifications. Reproduce with the shrunk minimal example, verify the property against docstrings and type annotations, and check whether the failing input is within the documented domain before reporting a bug.

When should I not use property-based testing?

Avoid property-based testing for simple CRUD operations without transformation logic, UI code, integration tests requiring external services, and throwaway scripts. It works best for unit-level pure functions with complex input domains.

How do I test Solidity smart contracts with property-based testing?

Use Echidna or Medusa fuzzers to test state invariants in EVM contracts. Write functions prefixed with echidna_ that return a boolean invariant, such as verifying balances remain non-negative, and the fuzzer generates transaction sequences to violate them.