Best use case
cargo-test is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Cargo test for Rust testing. Use for Rust testing.
Teams using cargo-test should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cargo-test/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How cargo-test Compares
| Feature / Agent | cargo-test | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Cargo test for Rust testing. Use for Rust testing.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Cargo Test
Rust treats testing as a first-class citizen. `cargo test` runs unit tests (in the same file), integration tests (in `tests/`), and uniquely, Documentation Tests (code blocks in your doc comments).
## When to Use
- **Rust Projects**: The standard.
- **Library Design**: Doc tests ensure your examples in README/Docs actually compile and work.
## Quick Start
```rust
// lib.rs
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(add(2, 2), 4);
}
}
```
## Core Concepts
### Unit vs Integration
- **Unit**: Inside `src/lib.rs` (or same file). Can test private functions.
- **Integration**: Inside `tests/*.rs`. Can only use the public API (like a real user).
### Doc Tests
Code blocks in `///` comments are run as tests.
````rust
/// Adds two numbers.
/// ```
/// let result = my_crate::add(2, 3);
/// assert_eq!(result, 5);
/// ```
pub fn add...
````
### Assertions
`assert!`, `assert_eq!`, `assert_ne!`. `#[should_panic]` for testing errors.
## Best Practices (2025)
**Do**:
- **Use `insta`**: For snapshot testing in Rust (`cargo-insta`).
- **Use `rstest`**: For fixture-based and parameterized testing (Pytest style).
- **Test concurrency**: Rust's ownership model makes testing concurrent code safer, but still verify with `loom` for atomics.
**Don't**:
- **Don't test implementation details in integration tests**: Keep `tests/` folder for Public API contracts only.
## References
- [Rust Book - Testing](https://doc.rust-lang.org/book/ch11-01-writing-tests.html)Related Skills
vitest
Vitest fast Vite-native testing. Use for Vite projects.
testng
TestNG Java testing framework. Use for Java testing.
testing-library
Testing Library user-centric testing. Use for React testing.
pytest
pytest Python testing framework with fixtures. Use for Python testing.
go-test
Go testing package. Use for Go testing.
cargo
Cargo Rust package manager and build system. Use for Rust crates.
template
Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].
zsh
Zsh shell with oh-my-zsh. Use for terminal shell.
zed
Zed high-performance collaborative editor. Use for fast editing.
xcode
Xcode Apple development IDE with simulators. Use for iOS/macOS development.
webstorm
WebStorm JavaScript IDE with debugging. Use for web development.
webpack
Webpack module bundler with loaders and plugins. Use for bundling.