charted-dev / testkit

πŸ“¦πŸ¦‹ TestKit is a Rust-based testing framework for HTTP-based services with Testcontainers support

Home Page:https://docs.rs/charted-testkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Noel (Trans Heart)

πŸ“¦πŸ¦‹ charted TestKit

charted TestKit is a testing library for Axum, which extends libtest with its own test macro. The library can also be used for only Testcontainers as well.

TestKit was built to make integration testing easier for Axum services with Testcontainers support and additional macros to help build assertions based off Responses.

Example

use charted_testkit::{test, TestContext, assert_successful, consume_body};
use axum::{body::Bytes, routing, Router};
use hyper::Method;

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

fn router() -> Router {
    Router::new().route("/", routing::get(hello))
}

#[test(router)]
async fn mytest(ctx: TestContext) {
    let res = ctx
        .request("/", Method::GET, None::<axum::body::Bytes>, |_| {})
        .await
        .expect("unable to send request");

    assert_successful!(res);

    let body = consume_body!(res);
    assert_eq!(body, Bytes::from_static(b"Hello, world!"));
}

License

TestKit is released under the MIT License with love and care by Noelware, LLC.! πŸ»β€β„οΈπŸ¦‹

Please read the LICENSE file in the canonical repository for more information on what you can do with the source code.

About

πŸ“¦πŸ¦‹ TestKit is a Rust-based testing framework for HTTP-based services with Testcontainers support

https://docs.rs/charted-testkit

License:MIT License


Languages

Language:Rust 79.9%Language:Nix 12.5%Language:Shell 7.6%