Skip to main content

Module client

Module client 

Source
Expand description

TestClient for integration testing without network binding

This module provides a test client that allows sending simulated HTTP requests through the full middleware and handler pipeline without starting a real server.

§Example

use rustapi_core::{RustApi, get};
use rustapi_testing::TestClient;

async fn hello() -> &'static str {
    "Hello, World!"
}

#[tokio::test]
async fn test_hello() {
    let app = RustApi::new().route("/", get(hello));
    let client = TestClient::new(app);
     
    let response = client.get("/").await;
    response.assert_status(200);
    assert_eq!(response.text(), "Hello, World!");
}

Structs§

TestClient
Test client for integration testing without network binding
TestRequest
Test request builder
TestResponse
Test response with assertion helpers