axum-tests

Test Axum web applications with unit and integration test patterns.

Updated Jun 15, 2025
One-click install
npx skills add https://github.com/patrickhaahr/dotfiles --skill axum-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: axum-tests
Source: https://github.com/patrickhaahr/dotfiles/tree/main/opencode/.config/opencode/skills/axum-tests
Command: npx skills add https://github.com/patrickhaahr/dotfiles --skill axum-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides structured guidance for testing Axum web applications, enabling developers to write reliable unit and integration tests with reusable patterns.

Core Features & Use Cases

  • Coverage of unit tests, integration tests, and test tooling for Axum handlers, extractors, middleware, and full application flows.
  • Examples using tower::ServiceExt, TestClient, and mocked state to illustrate deterministic testing strategies.
  • Use Case: A Rust backend using Axum can adopt these patterns to validate endpoints quickly and safely across modules.

Quick Start

Use the axum-tests skill to scaffold tests for a simple Axum route and verify response status and body.

Frequently Asked Questions about axum-tests

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

FAQPage Schema
How do I write integration tests for Axum web applications?

Integration tests for Axum web applications use tower::ServiceExt and TestClient to verify endpoint responses deterministically. You can scaffold tests for routes and validate response status codes and bodies using serde_json and tokio.

What is the best way to mock state in Axum tests?

Mocking state in Axum tests involves injecting simulated state structures into your application router for deterministic verification. This allows handlers and extractors to be tested in isolation without relying on real database connections.

Can I use tower::ServiceExt with Axum to test HTTP endpoints?

Yes, tower::ServiceExt works with Axum to test HTTP endpoints by allowing you to send requests directly to your application service. It provides a structured way to verify response status and body without starting a live server.

How do I test Axum middleware and extractors?

Testing Axum middleware and extractors requires structuring unit tests around specific layers and request extraction logic. You can use TestClient and mocked state to validate middleware behavior and extractor functionality in isolation.

Do I need axum-test to write end-to-end tests for Rust backends?

No, axum-test is an optional tooling dependency for end-to-end scenarios. You can achieve comprehensive testing using tower::ServiceExt and TestClient, though axum-test provides additional utilities for verifying full application flows.