rust-unit-tests

Automate creation, organization, and execution of Rust unit tests with cargo test.

64.1k|5.4k|Updated Jul 8, 2021
One-click install
npx skills add https://github.com/warpdotdev/warp --skill rust-unit-tests-warpdotdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-unit-tests
Source: https://github.com/warpdotdev/warp/tree/main/.agents/skills/rust-unit-tests
Command: npx skills add https://github.com/warpdotdev/warp --skill rust-unit-tests-warpdotdev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Warp Rust unit testing helps teams ensure correctness and maintainability by providing a clear guide to writing and running tests in the Warp codebase.

Core Features & Use Cases

  • Unit tests live in files named ${filename}_tests.rs or mod_test.rs
  • Include the test module at the end of the corresponding source file
  • Clear best-practice guidelines for naming tests, minimizing global state, and structuring test suites

Quick Start

Create a new file named filename_tests.rs and include it at the end of its corresponding source file.

Frequently Asked Questions about rust-unit-tests

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

FAQPage Schema
How do I organize Rust unit tests within a crate?

Organize Rust unit tests by placing them in dedicated files named filename_tests.rs or mod_tests.rs, then explicitly include the test module at the end of the corresponding source file.

How do I run Rust unit tests using cargo test?

Run Rust unit tests by executing cargo test in your project directory. This command automatically discovers and runs all functions within #[cfg(test)] modules across the codebase.

What are the best practices for structuring Rust test suites?

Best practices for structuring Rust test suites involve creating small, focused test modules, minimizing global state, and applying clear naming conventions to ensure correctness and maintainability.

Where should I put the #[cfg(test)] module in a Rust source file?

Put the #[cfg(test)] module at the end of your Rust source file. This explicit inclusion pattern keeps primary logic clean while enabling targeted unit testing for that specific file.

Does this Rust unit testing approach work for large crate-level codebases?

Yes, this approach works for crate-level tests across large Rust codebases. It emphasizes small, focused test modules and explicit inclusion patterns to maintain correctness and maintainability at scale.