2 releases

Uses new Rust 2021

0.1.1 Jul 3, 2022
0.1.0 Apr 28, 2022

#216 in Testing

Download history 191/week @ 2022-06-02 199/week @ 2022-06-09 185/week @ 2022-06-16 391/week @ 2022-06-23 272/week @ 2022-06-30 542/week @ 2022-07-07 622/week @ 2022-07-14 339/week @ 2022-07-21 595/week @ 2022-07-28 654/week @ 2022-08-04 644/week @ 2022-08-11 523/week @ 2022-08-18 524/week @ 2022-08-25 349/week @ 2022-09-01 669/week @ 2022-09-08 377/week @ 2022-09-15

2,008 downloads per month

MIT license

8KB
163 lines

axum-test-helper

axum-test-helper exposes axum original TestClient, which is private to the axum crate

More information about this crate can be found in the crate documentation.

High level features

  • Provide an easy to use interface
  • Start a server in a different port for each call
  • Deal with JSON, text and files response/requests

Usage example

Add this crate as a dev-dependency:

[dev-dependencies]
axum-test-helper = "0.1.1"

Use the TestClient on your own Router:

use axum::Router;
use axum::http::StatusCode;
use axum_test_helper::TestClient;

// you can replace this Router with your own app
let app = Router::new().route("/", get(|| async {}));

// initiate the TestClient with the previous declared Router
let client = TestClient::new(app);
let res = client.get("/").send().await;
assert_eq!(res.status(), StatusCode::OK);

You can find examples like this in the example directory.

See the crate documentation for way more examples.

License

This project is licensed under the MIT license.

Dependencies

~9–18MB
~354K SLoC