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. The macro takes no arguments.

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(())
}