Skip to main content

Crate azure_core_test_macros

Crate azure_core_test_macros 

Source
Expand description

§Azure client library test macros

Macros for testing client libraries built on azure_core. Read about the azure_core_test crate for more information about the generated code and how to write recorded tests.

🚨 WARNING 🚨: This project is not supported for anything other than testing Azure client libraries for Rust. The public API and behavior may change at any time.

§Client methods

To test client methods using our Test Proxy or to run against live resources, you can attribute asynchronous tests using the #[recorded::test] attribute:

use azure_core_test::{recorded, TestContext};

#[recorded::test]
async fn get_secret(ctx: TestContext) -> Result<(), Box<dyn std::error::Error>> {
    todo!()
}

The TestContext parameter is required unless your test function is attributed as #[recorded::test(live)] (live-only). You can name the parameter whatever you want. The TestContext parameter is used to initialize an HTTP client to play back or record tests and provides other information to test functions that may be useful.

These tests must also return a std::result::Result<T, E>, which can be redefined e.g., azure_core::Result<T>.

Attribute Macros§

test
Attribute client library tests to play back recordings, record sessions, or execute tests without recording.