[!IMPORTANT] We're excited you're checking out Hegel! Hegel is in beta, and we'd love for you to try it and report any feedback.
As part of our beta, we may make breaking changes if it makes Hegel a better property-based testing library. If that instability bothers you, please check back in a few months for a stable release!
See https://hegel.dev/compatibility for more details.
Hegel for Rust
hegel-rust is a property-based testing library for Rust. hegel-rust is based on Hypothesis, using the Hegel protocol.
Installation
To install: cargo add --dev hegeltest.
Hegel requires uv on your PATH, which we use to install the required hegel-core server component. See https://hegel.dev/reference/installation for details.
Quickstart
Here's a quick example of how to write a Hegel test:
use generators as gs;
use TestCase;
This test will fail! Integer addition panics on overflow. Hegel will produce a minimal failing test case for us:
Draw 1: 1
Draw 2: 2147483647
thread 'test_addition_commutative' (2) panicked at examples/readme.rs:8:16:
attempt to add with overflow
For a passing test, try: