#testing #test #axum


For spinning up and testing Axum servers

3 releases (stable)

2.0.0 Jan 17, 2023
1.0.0 Jan 14, 2023
0.2.3 Jan 12, 2023

#393 in HTTP server

MIT license

269 lines

Axum Test Server
for testing Axum Servers

crate docs

This has been moved to Axum Test, and you can find it here.

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.
      let server = TestServer::new_with_random_address(app);

      // Get the request.
      let response = server

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

One of the main benefits is you can spin up the server on a random port, allowing you to run multiple servers in parallel.


~205K SLoC