14 releases (7 major breaking)

new 9.1.0 Jun 1, 2023
8.1.0 May 28, 2023
7.3.0 Apr 22, 2023
7.2.0 Mar 30, 2023
2.0.0 Jan 17, 2023

#183 in HTTP server

Download history 9/week @ 2023-02-09 67/week @ 2023-02-16 51/week @ 2023-02-23 28/week @ 2023-03-02 29/week @ 2023-03-09 14/week @ 2023-03-16 19/week @ 2023-03-23 147/week @ 2023-03-30 116/week @ 2023-04-06 45/week @ 2023-04-13 90/week @ 2023-04-20 155/week @ 2023-04-27 89/week @ 2023-05-04 44/week @ 2023-05-11 74/week @ 2023-05-18 265/week @ 2023-05-25

484 downloads per month
Used in 2 crates

MIT license

1.5K SLoC

Axum Test
for testing Axum Servers

crate docs

This is a project to make it easier to test applications built using Axum. Using full E2E tests.

Some of the design decisions behind this are very opinionated, to encourage one to write good tests.


This is for spinning up an Axum service, that you can then query directly. This is primarily for testing Axum services.

  use ::axum::Router;
  use ::axum::routing::get;

  use ::axum_test_server::TestServer;

  async fn get_ping() -> &'static str {

  async fn it_sound_get() {
      // Build an application with a route.
      let app = Router::new()
          .route("/ping", get(get_ping))

      // Run the server on a random address.
      let server = TestServer::new(app).unwrap();

      // Get the request.
      let response = server

      assert_eq!(response.contents, "pong!");

Runs on a random port, allowing multiple to run at once

When you start the server, you can spin it up on a random port. It allows multiple E2E tests to run in parallel, each on their own webserver.

This behaviour can be changed in the TestServerConfig, by selecting a custom ip or port to always use.

Remembers cookies across requests

It is common in E2E tests that step 1 is to login, and step 2 is the main request. To make this easier cookies returned from the server will be preserved, and then included into the next request. Like a web browser.

Fails fast on unexpected requests

By default; all requests will panic if the server fails to return a 2xx status code. This can be switched to panic when the server doesn't return a 200.

This is a very opinionated design choice, and is done to help test writers fail fast when writing tests.


~216K SLoC