Command Palette

Search for a command to run...

Back to skills
skill № 45167

quality-property-based-testing

Use when the user asks about property-based testing, Hypothesis, fast-check, QuickCheck, generators and shrinking, invariants, stateful testing or fuzzing…

FreeNo executable scripts
j4flmaoby j4flmao★ 47 GitHub stars

Install quality-property-based-testing in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

Property-Based Testing

Purpose

Use property-based testing to define invariants and properties, generate random inputs, shrink failing cases, and discover edge cases that example-based testing misses. This skill covers generator design, property formulation, shrinking optimization, stateful testing, and CI integration.

Agent Protocol

Trigger

User mentions property-based testing, fuzzing, generative testing, QuickCheck, fast-check, Hypothesis, invariant testing, random testing, or asks about finding edge cases automatically.

Input Context

  • Functions or modules under test
  • Existing example-based test suite
  • Input type definitions and constraints
  • Business rule invariants
  • Performance requirements for test execution

Output Artifact

Property-based test suite with generators, property definitions, and CI integration configuration.

Response Format

Structured property test suite with:

  1. Property definitions (invariants, round-trips, metamorphic relations)
  2. Custom generator implementations (with shrinking)
  3. Stateful command models for stateful systems
  4. CI configuration for fast and thorough runs

Completion Criteria

  • Properties defined for all identified invariants
  • Generators produce valid domain inputs with < 10% rejection rate
  • Shrinking produces minimal counterexamples
  • CI integration with adaptive run depth (fast on commit, thorough nightly)
  • Failing seeds captured and counterexamples added as regression tests

Workflow

  1. Identify properties: Analyze the system under test; categorize properties as invariants, round-trips, idempotence, metamorphic, or stateful
  2. Design generators: Build generators for all input types using built-in generators, combinators, and custom arbitraries. Avoid heavy filtering
  3. Implement properties: Write property assertions using chosen framework (fast-check, Hypothesis, jqwik). Verify preconditions before postconditions
  4. Run and shrink: Execute with default run count (100). Verify shrinking produces actionable minimal counterexamples
  5. Analyze failures: Inspect shrunk inputs. Add counterexamples as regression tests. Store seeds for reproduction
  6. Optimize generators: Profile generation and shrinking performance. Replace filters with constrained generation. Reduce rejection rate
  7. Integrate CI: Configure CI with adaptive depth. Fast run (100 runs) on every commit. Thorough run (1000+ runs) nightly. Store seeds in build artifacts
  8. Add stateful models: For stateful systems, implement command-based models with preconditions, postconditions, and invariants
  9. Track metrics: Monitor property coverage, shrinking efficiency, counterexample discovery rate, and generator rejection rate
  10. Maintain property suite: Review properties during refactoring. Remove obsolete properties. Add new properties for modified code

Architecture / Decision Trees

Framework Selection Decision Tree

Inputs: language, team expertise, existing tooling
├── TypeScript/JavaScript → fast-check
│   ├── Stateful testing needed? → Use fc.Command + fc.modelRun
│   └── Async code? → Use fc.asyncProperty
├── Python → Hypothesis
│   ├── Stateful testing needed? → RuleBasedStateMachine
│   └── Pandas/NumPy? → pandas strategies
├── Java/Kotlin → jqwik
│   ├── Spring Boot? → Combine with Spring tests
│   └── Stateful testing? → StateMachine
└── Haskell → QuickCheck

Property Type Selection Decision Tree

Can you express a relation between input and output?
├── YES → Is the function an involution?
│   ├── YES → Reflective property: f(f(x)) == x
│   └── NO → Is the function idempotent?
│       ├── YES → Idempotence property: f(f(x)) == f(x)
│       └── NO → Round-trip property: decode(encode(x)) == x
└── NO → Can you express an invariant?
    ├── YES → Invariant property (e.g., output is sorted)
    └── NO → Metamorphic property: related inputs → related outputs

Common Pitfalls

  1. Heavy filtering in generators: Filter that rejects > 50% of values kills performance and shrinking. Replace with constrained generation (e.g., fc.integer({ min: 1 }) instead of fc.integer().filter(n => n > 0))
  2. Testing tautologies: Properties that can never fail (e.g., asserting the sum of two positive integers is positive when the generator only produces positive integers)
  3. Ignoring shrinking quality: If the shrunk output is still complex, the shrinker is not working well. Use constrained generators and avoid flatMap when possible
  4. Insufficient run count: Running only 10-20 random tests is not property-based testing. Minimum 100 runs; prefer 1000 for thorough validation
  5. No seed tracking: Failing to record the seed makes failures unreproducible. Always log seed and path
  6. Stateful test state pollution: Commands that share mutable state produce irreproducible failures. Each test run must start from a clean state
  7. Over-constrained generation: Generators that only produce "nice"
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • references/custom-generators.md
  • references/hypothesis-strategies.md
  • references/property-based-testing-advanced.md
  • references/property-based-testing-fundamentals.md
  • references/property-patterns.md
  • references/property-testing-architecture.md
  • references/property-testing-decision-framework.md
  • references/shrinking-guide.md
  • references/stateful-testing-deep.md
  • references/stateful-testing.md

FAQ

What does the quality-property-based-testing skill do?

Use when the user asks about property-based testing, Hypothesis, fast-check, QuickCheck, generators and shrinking, invariants, stateful testing or fuzzing. Produces properties, generators and stateful models. Not for example-based unit tests (use quality-unit-testing) or smart contract invariants (use blockchain-testing).

How do I install the quality-property-based-testing skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the quality-property-based-testing skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare quality-property-based-testing with