Attribute Macro cargo_fixture_macros::with_fixture

source ·
#[with_fixture]
Expand description

Annotate a test function as a fixture test.

The attribute marks the function with an appropriate cfg attribute to be #[ignore]d when the _fixture feature is not active, i.e. when not running under cargo fixture. It also wraps the function with a TestClient connection.

The function’s signature must be:

async fn foo(client: TestClient)

#[with_fixture] must come before attributes like #[tokio::test].

§Serial connection

To have the TestClient connected with serial set to true, use the serial syntax:

#[with_fixture(serial)]

§Example

#[with_fixture]
#[tokio::test]
async fn with_fixture_example(mut client: TestClient) {
    let example: Value = client.get_value("example").await.unwrap();
}