4 releases

0.2.0 Dec 19, 2022
0.1.2 Dec 19, 2022
0.1.1 Jul 3, 2022
0.1.0 Apr 28, 2022

#82 in Testing

Download history 327/week @ 2022-12-02 405/week @ 2022-12-09 996/week @ 2022-12-16 695/week @ 2022-12-23 1096/week @ 2022-12-30 1090/week @ 2023-01-06 1059/week @ 2023-01-13 749/week @ 2023-01-20 873/week @ 2023-01-27 1328/week @ 2023-02-03 1558/week @ 2023-02-10 1326/week @ 2023-02-17 1541/week @ 2023-02-24 1903/week @ 2023-03-03 1860/week @ 2023-03-10 1684/week @ 2023-03-17

7,229 downloads per month
Used in 3 crates

MIT license

9KB
167 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.*" # alternatively specify the version as "0.2.0"

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

~8–16MB
~323K SLoC