Attribute Macro madsim::test[][src]

#[test]
Expand description

Marks async function to be executed by runtime, suitable to test environment.

Example

#[madsim::test]
async fn my_test() {
    assert!(true);
}

Configuration

Test can be configured using the following environment variables:

  • MADSIM_TEST_SEED: Set the random seed for test.

    By default, the seed is set to the seconds since the Unix epoch.

  • MADSIM_TEST_NUM: Set the number of tests.

    The seed will increase by 1 for each test.

    By default, the number is 1.

  • MADSIM_TEST_TIME_LIMIT: Set the time limit for the test.

    The test will panic if time limit exceeded in the simulation.

    By default, there is no time limit.

  • MADSIM_TEST_CHECK_DETERMINISTIC: Enable deterministic check.

    The test will be run at least twice with the same seed. If any non-deterministic detected, it will panic as soon as possible.

    By default, it is disabled.