#[property_test]Expand description
Attribute macro for creating property-based tests
This macro transforms a regular test function into a property-based test by automatically generating test data and integrating with the Protest testing framework.
§Basic Usage
use protest::property_test;
#[property_test]
fn test_addition_commutative(a: i32, b: i32) {
assert_eq!(a + b, b + a);
}§Configuration Attributes
The macro supports various configuration attributes:
use protest::property_test;
#[property_test(iterations = 1000, seed = 42)]
fn test_with_config(x: u32) {
assert!(x >= 0);
}§Supported Attributes
iterations = N: Number of test iterations (default: 100)seed = N: Random seed for reproducible testsmax_shrink_iterations = N: Maximum shrinking attempts (default: 1000)shrink_timeout_secs = N: Shrinking timeout in seconds (default: 10)
§Async Support
The macro automatically detects async functions and uses async property testing:
use protest::property_test;
#[property_test]
async fn test_async_operation(data: String) {
let result = some_async_operation(&data).await;
assert!(!result.is_empty());
}§Generator Inference
The macro automatically infers generators for function parameters based on their types.
For custom types, ensure they implement the Generator trait or derive it.