rustapi-testing

Crates.iorustapi-testing
lib.rsrustapi-testing
version0.1.207
created_at2026-01-14 03:45:53.58336+00
updated_at2026-01-26 00:02:49.393074+00
descriptionTesting utilities for RustAPI applications. Provides checking helpers, test servers, and fluid assertions.
homepagehttps://github.com/Tuntii/RustAPI
repositoryhttps://github.com/Tuntii/RustAPI
max_upload_size
id2042104
size121,721
Tunay (Tuntii)

documentation

https://docs.rs/rustapi-testing

README

RustAPI Testing

A fluid, ergonomic test harness for RustAPI applications.

Don't just test your logic; test your endpoints.

Features

  • TestClient: Spawns your application directly (no port binding needed) and sends requests.
  • Fluid Assertions: res.assert_status(200).assert_json(&expected).
  • Mocking: Utilities to swap out state/databases during tests.

Example

#[cfg(test)]
mod tests {
    use rustapi_testing::TestClient;
    use rustapi_rs::prelude::*;

    #[tokio::test]
    async fn test_create_user() {
        // 1. Setup app
        let app = RustApi::new().mount_route(create_user_route());
        let client = TestClient::new(app);

        // 2. Execute
        let response = client.post("/users")
            .json(&json!({ "name": "Alice" }))
            .send()
            .await;

        // 3. Assert
        response
            .assert_status(StatusCode::OK)
            .assert_json_path("$.id", 1);
    }
}
Commit count: 208

cargo fmt