Crate protest

Crate protest 

Source
Expand description

§Protest - Property-Based Testing for Rust

Protest is a property-based testing library that provides an intuitive API for generating random test data, executing property tests with configurable parameters, and shrinking failing cases to minimal examples.

§Quick Start

use protest::{just, range, Strategy};
use rand::thread_rng;

// Create a simple strategy
let strategy = range(1, 100);
let mut rng = thread_rng();
let config = protest::GeneratorConfig::default();

// Generate a value
let value = strategy.generate(&mut rng, &config);
assert!(value >= 1 && value <= 100);

Re-exports§

pub use arbitrary::Arbitrary;
pub use config::ConfigError;
pub use config::ConfigManager;
pub use config::GeneratorConfig;
pub use config::GlobalConfig;
pub use config::TestConfig;
pub use config::create_test_config;
pub use config::create_test_config_with_overrides;
pub use config::get_global_config;
pub use config::set_global_config;
pub use error::PropertyError;
pub use execution::AsyncPropertyTest;
pub use execution::PropertyTest;
pub use execution::PropertyTestBuilder;
pub use execution::check;
pub use execution::check_async;
pub use execution::check_async_with_config;
pub use execution::check_with_config;
pub use generator::BoxedGenerator;
pub use generator::ConstantGenerator;
pub use generator::Generator;
pub use generator::GeneratorRegistry;
pub use generator::OneOfGenerator;
pub use performance::LazyGenerator;
pub use performance::ParallelConfig;
pub use performance::ParallelPropertyTest;
pub use performance::StreamingShrinkStrategy;
pub use performance::check_parallel;
pub use performance::lazy;
pub use property::AsyncProperty;
pub use property::Property;
pub use rng::DefaultRngProvider;
pub use rng::RngManager;
pub use rng::RngProvider;
pub use rng::create_rng;
pub use rng::create_seeded_rng;
pub use shrink::AsyncShrinkEngine;
pub use shrink::ShrinkConfig;
pub use shrink::ShrinkEngine;
pub use shrink::ShrinkResult;
pub use shrink::Shrinkable;
pub use statistics::CoverageThresholdsBuilder;
pub use statistics::StatisticsCollector;
pub use strategy::Strategy;
pub use test_runner::DefaultFormatter;
pub use test_runner::JsonFormatter;
pub use test_runner::TestContext;
pub use test_runner::TestOutputFormatter;
pub use test_runner::TestResult;
pub use test_runner::TestRunner;
pub use test_runner::VerboseFormatter;
pub use error::PropertyResult;
pub use error::TestFailure;
pub use error::TestSuccess;
pub use strategy::just;
pub use strategy::one_of;
pub use strategy::range;
pub use primitives::*;

Modules§

arbitrary
Arbitrary trait and related functionality for automatic test data generation.
config
Configuration types for controlling test behavior and generation parameters.
ergonomic
Ergonomic APIs for property-based testing
error
Error types and result handling for property-based testing.
execution
Property test execution engine for running synchronous and asynchronous property tests.
generator
Core generator infrastructure and registry system.
performance
Performance optimizations for property testing including parallel execution, lazy evaluation, and memory-efficient strategies.
primitives
Generators for primitive types and basic collections.
property
Property definition traits for synchronous and asynchronous testing.
rng
RNG backend integration and provider system.
shrink
Shrinking functionality for minimizing failing test cases.
statistics
Statistics collection and analysis for property-based testing.
strategy
Strategy-based generation system for composable test data creation.
test_runner
Test runner integration and compatibility utilities

Macros§

assert_property
Assert that a property holds, panicking if it fails
generator
Create a generator for a given type
property
Create and run a property test with minimal syntax
test_builder
Macro for creating fluent property test builders

Attribute Macros§

property_test
Attribute macro for creating property-based tests

Derive Macros§

Generator
Derive macro for automatically implementing the Generator trait