backend-test-kit 0.0.2

Provides a set of tools and helpers for testing backend services in Rust.
Documentation
  • Coverage
  • 0%
    0 out of 11 items documented0 out of 3 items with examples
  • Size
  • Source code size: 41.93 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.09 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 59s Average build duration of successful builds.
  • all releases: 56s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ukasyah-dev

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;
}