axum-impl-testing

Create deterministic Axum test workflows using oneshot, TestServer, and shared app constructors.

Updated May 20, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/Axum-Claude-Skill-Package --skill axum-impl-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: axum-impl-testing
Source: https://github.com/Impertio-Studio/Axum-Claude-Skill-Package/tree/main/skills/source/axum-impl/axum-impl-testing
Command: npx skills add https://github.com/Impertio-Studio/Axum-Claude-Skill-Package --skill axum-impl-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents flaky or misleading Axum tests by ensuring every test drives the same fully configured app wiring, with correct handling of JSON request content types and response body collection. It also avoids common integration-test breakages where tests/ can’t access a private app() constructor, and it fixes compile-time failures caused by reusing a consumed oneshot service across multiple requests.

Core Features & Use Cases

  • Shared app() constructor discipline: Route unit and integration tests through one shared app() (or pub fn app(...)) so tests prove the real shipped wiring.
  • Two deterministic testing approaches: Use tower::ServiceExt::oneshot for fast handler/unit tests or axum-test::TestServer for ergonomic integration tests with fluent assertions.
  • Correct JSON and body reading: Set Content-Type: application/json for raw JSON oneshot requests to avoid MissingJsonContentType/415, and always read response bodies via into_body() + http_body_util::BodyExt::collect() before inspecting bytes.
  • Multi-request sequencing: Use .into_service() plus ready()/call() when you need multiple requests against one app instance.
  • Integration test visibility: Export app() from src/lib.rs so tests/ crates can import it successfully.

Quick Start

Use the axum-impl-testing skill to write a deterministic #[tokio::test] that either sends a JSON request via oneshot with the correct Content-Type header or uses axum-test::TestServer with fluent assertions, all built from a shared pub fn app() constructor.

Frequently Asked Questions about axum-impl-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do my Axum integration tests return 415 Unsupported Media Type when sending JSON?

Axum integration tests return 415 when raw JSON requests lack the Content-Type header. Setting Content-Type: application/json on oneshot requests prevents MissingJsonContentType rejections.

How do I run multiple test requests against one Axum app instance without compile errors?

Running multiple Axum test requests requires converting the router with into_service and using ready and call methods. This approach avoids compile-time failures caused by reusing a consumed oneshot service.

How do I read an Axum test response body without causing panics or incomplete reads?

Reading Axum test response bodies requires calling into_body and using http_body_util BodyExt collect. This guarantees full body consumption before inspecting the returned bytes for assertions.

Why can't my Axum tests directory access the app router constructor?

The tests directory cannot access a private app constructor. Exporting a public app function from src/lib.rs allows integration tests to import and use the real router wiring successfully.

What is the best way to write deterministic Axum handler tests with real wiring?

Deterministic Axum handler tests use a shared public app constructor and tower ServiceExt oneshot. This drives the real router wiring and produces reliable assertions for unit tests.

Can I use axum-test TestServer for integration tests with fluent assertions?

Yes, axum-test TestServer supports ergonomic Axum integration tests with fluent assertions. It provides a reliable alternative to oneshot for testing fully configured app wiring.