| Crates.io | axum-test-helper |
| lib.rs | axum-test-helper |
| version | 0.4.0 |
| created_at | 2022-04-28 23:44:36.593763+00 |
| updated_at | 2024-07-28 20:36:18.022691+00 |
| description | Extra utilities for axum |
| homepage | https://github.com/cloudwalk/axum-test-helper |
| repository | https://github.com/cloudwalk/axum-test-helper |
| max_upload_size | |
| id | 577064 |
| size | 14,003 |
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.
Add this crate as a dev-dependency:
[dev-dependencies]
axum-test-helper = "0.*" # alternatively specify the version as "0.3.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.
By default axum-test-helper print trace like Listening on 127.0.0.1:36457. You can disable trace with axum-test-helper = { version = "0.*", default-features = false, features = ["withouttrace"] }.
Before submitting a pull request or after pulling from the main repository, ensure all tests pass:
# Run axum-test-helper tests
cargo test
# Test the hello-world example project
(cd examples/hello-world && cargo test)
This project is licensed under the MIT license.