[][src]Attribute Macro two_rusty_forks_macro::test_fork

#[test_fork]

Run Rust tests in subprocesses.

The basic usage is to simply put this macro around your test functions.

#[cfg(test)]
mod test {
    use two_rusty_forks::test_fork;

    #[test_fork]
    fn my_test() {
        assert_eq!(2, 1 + 1);
    }

    // more tests...
}

Each test will be run in its own process. If the subprocess exits unsuccessfully for any reason, including due to signals, the test fails.

It is also possible to specify a timeout which is applied to all tests in the block, like so:

use two_rusty_forks::test_fork;

#[test_fork(timeout_ms = 1000)]
fn my_test() {
    do_some_expensive_computation();
}

If any individual test takes more than the given timeout, the child is terminated and the test panics.

Using the timeout feature requires the timeout feature for this crate to be enabled (which it is by default).