[][src]Attribute Macro tokio::test

#[test]
This is supported on crate features rt-threaded and macros only.

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

Options:

  • core_threads=n - Sets core threads to n (requires rt-threaded feature).
  • max_threads=n - Sets max threads to n (requires rt-core or rt-threaded feature).

Usage

Select runtime

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

Using default

#[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.2 version of tokio because you're also using the 0.1 version of tokio, you must make the tokio 0.2 crate available as tokio in the module where this macro is expanded.