Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/charted-dev/testkit
📦🦋 TestKit is a Rust-based testing framework for HTTP-based services with Testcontainers support
https://github.com/charted-dev/testkit
axum charted rust rustlang testkit
Last synced: 9 days ago
JSON representation
📦🦋 TestKit is a Rust-based testing framework for HTTP-based services with Testcontainers support
- Host: GitHub
- URL: https://github.com/charted-dev/testkit
- Owner: charted-dev
- License: mit
- Created: 2024-05-02T21:03:46.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-12-08T05:02:13.000Z (19 days ago)
- Last Synced: 2024-12-08T05:18:22.153Z (19 days ago)
- Topics: axum, charted, rust, rustlang, testkit
- Language: Rust
- Homepage: https://docs.rs/charted-testkit
- Size: 62.5 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# 📦🦋 charted TestKit
charted **TestKit** is a testing library for [Axum](https://github.com/tokio-rs/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
```rust
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::, |_| {})
.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](/LICENSE) with love and care by [Noelware, LLC.](https://noelware.org)! 🐻❄️🦋Please read the `LICENSE` file in the [canonical repository](https://github.com/charted-dev/testkit) for more information on what you can do with the source code.
[`Response`]: https://docs.rs/http/latest/http/response/struct.Response.html
[`libtest`]: https://doc.rust-lang.org/stable/test
[`test`]: #