backend-test-kit

Crates.iobackend-test-kit
lib.rsbackend-test-kit
version0.0.2
created_at2025-01-25 12:39:20.932141+00
updated_at2025-01-25 23:36:34.051255+00
descriptionProvides a set of tools and helpers for testing backend services in Rust.
homepage
repositoryhttps://github.com/ukasyah-dev/backend-test-kit
max_upload_size
id1530568
size42,421
Ukasyah (ukasyah-dev)

documentation

README

backend-test-kit

Provides a set of tools and helpers for testing backend services in Rust.

Quickstart

Add backend-test-kit as a dev dependency:

cargo add --dev backend-test-kit

Here's a simple example of how to use it:

use std::vec;

use backend_test_kit::http::{TestCase, TestSuite};
use serde_json::json;

#[tokio::test]
async fn create_post() {
    let test_cases = vec![
        TestCase {
            json: Some(json!({
                "title": "foo",
                "body": "bar",
                "userId": 1,
            })),
            expect_status: |s| assert!(s.is_success()),
            expect_result: |r| {
                assert_eq!(r["id"], 101);
                assert_eq!(r["title"], "foo");
                assert_eq!(r["body"], "bar");
            },
        },
    ];

    let test_suite = TestSuite {
        method: "POST".to_string(),
        url: "https://jsonplaceholder.typicode.com/posts".to_string(),
        test_cases,
    };

    test_suite.run().await;
}
Commit count: 0

cargo fmt