macro_rules! prop_state_machine {
    (#![proptest_config($config:expr)]
    $(
        $(#[$meta:meta])*
        fn $test_name:ident(sequential $size:expr => $test:ident $(< $( $ty_param:tt ),+ >)?);
    )*) => { ... };
    ($(
        $(#[$meta:meta])*
        fn $test_name:ident(sequential $size:expr => $test:ident $(< $( $ty_param:tt ),+ >)?);
    )*) => { ... };
}
Expand description

This macro helps to turn a state machine test implementation into a runnable test. The macro expects a function header whose arguments follow a special syntax rules: First, we declare if we want to apply the state machine transitions sequentially or concurrently (currently, only the sequential is supported). Next, we give a range of how many transitions to generate, followed by => and finally, an identifier that must implement StateMachineTest.

§Example

struct MyTest;

impl StateMachineTest for MyTest {}

prop_state_machine! {
    #[test]
    fn run_with_macro(sequential 1..20 => MyTest);
}

This example will expand to:

struct MyTest;

impl StateMachineTest for MyTest {}

proptest! {
    #[test]
    fn run_with_macro(
        (initial_state, transitions) in MyTest::sequential_strategy(1..20)
    ) {
       MyTest::test_sequential(initial_state, transitions)
    }
}