Expand description

Β§π¦π¦ 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 Response
s.
Β§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.
MacrosΒ§
- assert_
doesnt_ have_ header - Assertion macro to indicate that a
Response
doesnβt have the header it needs. - assert_
failure - Checks whenever if a
Response
failed. - assert_
has_ header - Assertion macro to indicate that a
Response
has the header it needs. - assert_
status_ code - Macro to easily assert if a given responseβs status code is the same as one you provide.
- assert_
successful - Checks whenever if a
Response
is successful or not. - consume_
body - Macro to consume the full body of a response and returns
a
Bytes
container.
StructsΒ§
FunctionsΒ§
- noop_
request - A empty function that can be used with
TestContext::request
.
Attribute MacrosΒ§
- test
- Represents a procedural attribute macro that does the heavy lifting of
charted_testkit
for you. This macro also manages: