Skip to main content

test

Attribute Macro test 

Source
#[test]
Expand description

Runs an async test on the ntex runtime.

Re-exported as ntex::test.

The macro adds #[test], unless the function already has it, and runs the body on a new System named after the test. The system is built in testing mode, without signal and panic handling, and always uses ntex::rt::DefaultRuntime. The test can return a Result, like a normal test.

ยงArguments

  • timer_resolution = N - resolution of the timer wheel in milliseconds, a power of two between 1 and 16. Defaults to 16.
  • task_callbacks = path - a fn() -> ntex::rt::TaskCallbacks factory, as for [rt_main].

Other arguments, including the rest of those of [rt_main], are a compile error. Build a System manually for any other runtime configuration.

It also turns on env_logger at trace level, unless RUST_LOG is set. Set NTEX_NO_TEST_LOG or enable the no-test-logging feature of ntex to turn logging off.

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

#[ntex::test]
async fn my_fallible_test() -> std::io::Result<()> {
    Ok(())
}

#[ntex::test(timer_resolution = 1)]
async fn my_precise_timer_test() {}