Skip to content

audunska/axum-test-helper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Easy to use axum test client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%