fallibles
Fallibles enables controlled failure injection for testing error handling in Rust applications.
Mark functions with #[fallible] and configure when they should fail for comprehensive testing.
Features
fallibles-sim- Enable failure injection (required)std- Standard library support (default)anyhow- Support for anyhow::Erroreyre- Support for eyre::Report
Quick Start
use *;
// Enable 30% failure rate
configure_failures;
Examples
Basic Usage
use *;
// Without config, function always succeeds
assert_eq!;
// Enable failures with RAII guard
// Config automatically cleared
Inline Configuration
use *;
// 20% failure rate
// Fail every 5th call
Policy-Based Testing
use ;
// Chaos Monkey: 10% random failures
let _guard = with_config;
// Degraded Service: 30% failures
let _guard = with_config;
// Circuit Breaker: fail every 5th call
let _guard = with_config;
Conditional Failures
use ;
// Only fail when environment variable is set
let _guard = with_config;
Reproducible Testing
use ;
// Same seed always produces same failure pattern
let _guard = with_config;
// Or from environment: FALLIBLES_SEED=12345 cargo test
Custom Error Types
use *;