property-testing

Write property-based tests in Rust using the hegel library with generators, shrinking, and replay.

Updated Aug 5, 2026
One-click install
npx skills add https://github.com/harivansh-afk/loom-index-e2e --skill property-testing-harivansh-afk
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: property-testing
Source: https://github.com/harivansh-afk/loom-index-e2e/tree/main/skills/property-testing
Command: npx skills add https://github.com/harivansh-afk/loom-index-e2e --skill property-testing-harivansh-afk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Example-based unit tests only cover the inputs you think of, leaving parsers, converters, and codecs exposed to panics and edge cases on unexpected data. This Skill guides you through property-based testing with hegel, Antithesis's Hypothesis-based Rust library, so generated inputs, automatic shrinking, and failure replay find real counterexamples for you. ## Core Features & Use Cases - Property Selection Guidance: Prioritizes high-value properties such as never-panics, round-trip, determinism, idempotence, and model-based comparison against a reference implementation. - Generator Patterns: Covers recursive structures with gs::deferred, bounded vectors with max_size, composite generators, and keeping generated programs well-formed by construction. - Budget, Replay, and CI Determinism: Explains test_cases budgets, the .hegel failure database, and how to convert shrunk counterexamples into regression tests for CI. - Use Case: When fuzzing a Nix-to-TypeScript transpiler, generate well-formed source, assert the output parses under an independent parser like rnix, and let hegel shrink any failure to a minimal case you copy into a regression test. ## Quick Start Add property-based tests to my Rust parser crate using hegel so it never panics on arbitrary text input.

Frequently Asked Questions about property-testing

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

FAQPage Schema
How do I write property-based tests in Rust?▼

Use the hegel library with the #[hegel::test] attribute under plain cargo test. Define generators with gs combinators like gs::text() or gs::vecs, assert a property such as round-trip equality, and hegel automatically shrinks failures to a minimal counterexample.

What properties should I test when fuzzing a parser?▼

Start with a never-panics property feeding arbitrary text or bytes and asserting Ok or Err rather than a panic. Then add round-trip, determinism, and idempotence checks, and finally model-based comparison against an obviously-correct reference implementation.

Does hegel work inside Nix sandboxed builds?▼

Yes, hegel runs unchanged inside Nix sandboxes. The engine and macros come from crates.io as the hegeltest package with default-features disabled, requiring no Python and no network access at test time.

Why does my property test pass even when the code is broken?▼

The generator is usually at fault, for example iterating a collected set that is always empty. Invert a new property once and watch it fail to confirm the generator produces meaningful inputs, then restore the real assertion.

How do I reproduce a hegel failure in CI?▼

Hegel stores counterexamples in a .hegel failure database for local replay, but CI sandboxes start fresh. Copy the printed shrunk case into a regression #[test] alongside the fix, and never re-run a red CI property to green.

When should I enable the antithesis feature in hegel?▼

Only for workloads launched through the antithesis-* skills on the Antithesis platform, where the feature wires assertions into its SDK. Do not enable it for ordinary CI runs.