Module testing

Module testing 

Source
Expand description

Test utilities for the Application Container

Provides mechanisms for test isolation via thread-local container overrides.

§Example

use kit::testing::{TestContainer, TestContainerGuard};

#[tokio::test]
async fn test_with_fake_service() {
    // Set up test container - automatically cleared when guard is dropped
    let _guard = TestContainer::fake();

    // Register fake implementations
    TestContainer::bind::<dyn HttpClient>(Arc::new(FakeHttpClient::new()));

    // App::make() will now return the fake
    let client: Arc<dyn HttpClient> = App::make::<dyn HttpClient>().unwrap();
}

Structs§

TestContainer
Test utilities for the container
TestContainerGuard
Guard that clears the test container when dropped