Attribute Macro tokio::test[][src]

#[test]

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

Usage

Multi-thread runtime

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn my_test() {
    assert!(true);
}

Using default

The default test runtime is single-threaded.

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

NOTE:

If you rename the tokio crate in your dependencies this macro will not work. If you must rename the 0.3 version of tokio because you’re also using the 0.1 version of tokio, you must make the tokio 0.3 crate available as tokio in the module where this macro is expanded.