How can I create parameterized tests in Rust?

后端 未结 6 2073
生来不讨喜
生来不讨喜 2021-02-05 01:20

I want to write test cases that depend on parameters. My test case should be executed for each parameter and I want to see whether it succeeds or fails for each parameter.

6条回答
  •  清歌不尽
    2021-02-05 01:40

    Use https://github.com/frondeus/test-case crate.

    Example:

    #[test_case("some")]
    #[test_case("other")]
    fn works_correctly(arg: &str) {
        assert!(arg.len() > 0)
    }
    

提交回复
热议问题