rust-tests

Design and validate Rust test suites for Axum services using oneshot patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Solves the problem of designing and validating robust Rust test suites (unit, integration, and doc tests) for Axum-based services.

Core Features & Use Cases

  • Unit tests colocated with code (mod tests) to test private logic and ensure quick feedback.
  • Integration tests in the tests/ directory to validate public APIs and crate boundaries.
  • Doc tests embedded in code examples to demonstrate usage and verify examples run as tests.
  • Async HTTP testing patterns for Axum/Tower apps using tower::ServiceExt::oneshot for fast, deterministic requests.
  • Test organization guidance and best practices for isolating tests and avoiding global state.
  • Use Case: When building a Rust library or AXUM service, use this Skill to design robust test suites that catch regressions quickly.

Quick Start

Run cargo test to execute all Rust tests (unit, integration, and doc tests) and verify Axum route handlers, enabling fast feedback.

Frequently Asked Questions about rust-tests

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

FAQPage Schema
How do I test Axum route handlers without spinning up a live server?

Use the tower::ServiceExt::oneshot pattern to send deterministic HTTP requests directly to your Axum router. This approach enables fast, isolated route testing without the overhead of binding to a network port.

What's the best way to organize Rust tests for a library and HTTP service?

Organize Rust tests by colocating unit tests in a mod tests block for private logic, placing integration tests in the tests/ directory for public API boundaries, and embedding doc tests in code examples to verify usage.

Does cargo test automatically run unit, integration, and doc tests for Rust projects?

Yes, cargo test executes unit, integration, and doc tests by default. This provides quick feedback by validating colocated private logic, crate boundaries, and embedded code examples in a single command.

How do I isolate Rust integration tests to avoid global state bleeding between test cases?

Isolate Rust integration tests by following organizational best practices that avoid global state. Design each test case in the tests/ directory to validate public API boundaries independently for deterministic results.

When should I use unit tests instead of integration tests in a Rust Axum project?

Use unit tests colocated with your code to test private internal logic quickly. Use integration tests in the tests/ directory when you need to validate public APIs and crate boundaries across your Axum service.