Attribute Macro serial_test::serial

source · []
#[serial]
Expand description

Allows for the creation of serialised Rust tests

#[test]
#[serial]
fn test_serial_one() {
  // Do things
}

#[test]
#[serial]
fn test_serial_another() {
  // Do things
}

Multiple tests with the serial attribute are guaranteed to be executed in serial. Ordering of the tests is not guaranteed however. If you have other tests that can be run in parallel, but would clash if run at the same time as the serial tests, you can use the parallel attribute.

If you want different subsets of tests to be serialised with each other, but not depend on other subsets, you can add an argument to serial, and all calls with identical arguments will be called in serial. e.g.

#[test]
#[serial(something)]
fn test_serial_one() {
  // Do things
}

#[test]
#[serial(something)]
fn test_serial_another() {
  // Do things
}

#[test]
#[serial(other)]
fn test_serial_third() {
  // Do things
}

#[test]
#[serial(other)]
fn test_serial_fourth() {
  // Do things
}

test_serial_one and test_serial_another will be executed in serial, as will test_serial_third and test_serial_fourth but neither sequence will be blocked by the other

Nested serialised tests (i.e. a serial tagged test calling another) are supported