Engineering
property-based-testing avatar

property-based-testing

Automated guidance for implementing property-based testing (PBT) in software and smart contracts to improve test coverage and edge case detection.

Introduction

The Property-Based Testing (PBT) skill provides a comprehensive framework for replacing or augmenting traditional example-based tests with property-driven approaches. Designed for developers and security auditors working on complex logic, it focuses on areas where standard unit tests often fail to catch subtle bugs, such as serialization routines, data parsing, cryptographic algorithms, and smart contract state invariants. By leveraging this skill, users can systematically define properties like roundtrip, idempotence, and commutativity to ensure software behaves correctly across a vast state space of randomized inputs.

  • Automatically detects high-value candidates for PBT including encode/decode pairs, parsers, normalizers, validators, and algorithmic transformations.

  • Provides a structured Decision Tree to help developers choose the right PBT strategy based on their current task, such as designing new features, refactoring for testability, or interpreting test failures.

  • Includes a robust catalog of properties (e.g., Roundtrip, Idempotence, Invariant, Oracle, and No Exception) with concrete formulas and usage guidance.

  • Offers integration advice for common PBT libraries and frameworks like Hypothesis, fast-check, proptest, and Echidna for Solidity.

  • Provides a strength hierarchy to guide developers from weak 'No Exception' tests toward strong 'Roundtrip' and 'Invariant' verification.

  • When invoking this skill, provide context on the code block, such as whether it is a parser, serializer, or smart contract function, to receive specific property suggestions.

  • The skill is intended for unit and component testing; avoid using it for integration tests or code with non-deterministic side effects like external network calls or database writes.

  • Use the provided checklists during code reviews to identify anti-patterns where PBT would offer significantly stronger coverage than static, hardcoded example cases.

  • If a test fails, the skill provides specific guidance on analyzing the failure, including how to simplify counter-examples and distinguish between valid implementation bugs and overly restrictive property definitions.

Repository Stats

Stars
4,874
Forks
424
Open Issues
21
Language
Python
Default Branch
main
Sync Status
Idle
Last Synced
Apr 29, 2026, 07:27 AM
View on GitHub