test_suite_rs

Crates.iotest_suite_rs
lib.rstest_suite_rs
version0.1.4
sourcesrc
created_at2023-04-21 16:04:49.729438
updated_at2023-08-01 08:01:03.075058
descriptionProvides a macro to create a test suite with a setup and teardown function
homepagehttps://github.com/Aeradriel/test_suite_rs
repositoryhttps://github.com/Aeradriel/test_suite_rs
max_upload_size
id845445
size11,516
Thibaut Roche (Aeradriel)

documentation

https://docs.rs/test_suite

README

test_suite_rs

Provides a macro to create a test suite with a setup and teardown function. Each test block generates a separate test function that will run setup and teardown functions if provided.

Example

use test_suite_rs::test_suite;

fn setup() -> (i32, String) {
    (43, "my_string".to_owned())
}

fn teardown() {}

test_suite! {
    - name: test_mod
    - setup: setup(i32, String)
    - teardown: teardown

    test should_return_true(nbr, my_string) {
        assert_eq!(nbr, 43);
        assert_eq!(&my_string, "my_string");
    }

    test should_return_false {
        assert!(true);
    }
}

Generates the following code (simplified):

mod test_mod {
    use super::*;

    #[test]
    fn should_return_true() {
        let (nbr, my_string) = setup();

        assert_eq!(nbr, 43);
        assert_eq!(&my_string, "my_string");
        teardown();
    }
    
    #[test]
    fn should_return_false() {
        assert!(true);
    }
}
Commit count: 14

cargo fmt