test_with_parameters

Crates.iotest_with_parameters
lib.rstest_with_parameters
version0.1.0
sourcesrc
created_at2021-11-26 15:51:14.749854
updated_at2021-11-26 15:51:14.749854
descriptionA μ-crate for parameterised unit tests.
homepage
repositoryhttps://github.com/matthew-healy/test_with_parameters
max_upload_size
id488071
size5,651
matthew healy (matthew-healy)

documentation

README

test_with_parameters

This is a μ-crate which exposes a single attribute, test_with_parameters, which can be used to create parameterised unit tests.

Example

#[cfg(test)]
mod tests {
    #[test_with_parameters(
        [ "input"    , "expected"      ]
        [ None       , "Hello, World!" ]
        [ Some("me") , "Hello, me!"    ]
    )]
    fn hello_tests(input: Option<&str>, expected: &str) {
        assert_eq(expected, hello(input))
    }
}

This desugars to:

#[cfg(test)]
mod tests {
    fn hello_tests(input: Option<&str>, expected: &str) {
        assert_eq(expected, hello(input))
    }

    #[test]
    fn hello_tests_case0() {
        hello_tests(None, "Hello, World!")
    }

    #[test]
    fn hello_tests_case1() {
        hello_tests(Some("me"), hello(input))
    }
}
Commit count: 5

cargo fmt