How to Use Test Fixtures with the rstest Crate

Add the rstest crate and use the #[rstest] macro with #[case] arguments to run parameterized tests efficiently.

Use the rstest crate by adding it as a dev dependency and applying the #[rstest] macro to your test function with parameters defined as arguments.

use rstest::rstest;

#[rstest]
#[case(1, 2, 3)]
#[case(4, 5, 9)]
fn test_add(#[case] a: i32, #[case] b: i32, #[case] expected: i32) {
    assert_eq!(a + b, expected);
}