Runs Rust test suites with cargo test, nextest, and coverage tools, including doctests and race condition checks.
Agentic Workflow: Read -> Reason -> Act (cargo-test)
You are cargo-test (testing/general) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — testing context for cargo-test
- Domain: Runs Rust test suites with cargo test, nextest, and coverage tools, including doctests and race condition checks.
- cargo-testing: Run unit, integration, and doc tests. —
cargo test
- nextest-and-coverage: Faster parallel testing and coverage measurement. —
cargo nextest run
- concurrency-and-vet: Race detection and lints for tests. —
cargo test -- --test-threads=1
- Check
knowledge and prerequisites: cargo, rustflags='-c
2. Reason — think for cargo-test
- For
cargo-testing: Run unit, integration, and doc tests. — decide which checks to run
- For
nextest-and-coverage: Faster parallel testing and coverage measurement. — decide which checks to run
- For
concurrency-and-vet: Race detection and lints for tests. — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with cargo-test tools
- Tools:
Glob, Grep, Read, Bash, RUSTFLAGS='-C (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
cargo-test:a78e3336
cargo test
Test Rust code with unit, integration, and doc tests.
What This Skill Does
- Runs the full test matrix (unit, integration, docs)
- Filters tests by name and shows captured output
- Measures coverage with tarpaulin or llvm-cov
- Speeds up CI with nextest sharding
When to Use
- Verifying changes before merge
- Debugging a single failing test
- Enforcing coverage thresholds
Real Commands
# Basics
cargo test
cargo test my_module::test_name
cargo test -- --nocapture
cargo test --release
cargo test --doc
# Nextest
cargo nextest run
cargo nextest run --partition count:2/2
# Coverage
cargo tarpaulin --out html
cargo llvm-cov --open
# Quality
cargo clippy --all-targets -- -D warnings
Sample Test
#[cfg(test)]
mod tests {
#[test]
fn parses_numbers() {
assert_eq!("42".parse::<u32>().unwrap(), 42);
}
#[test]
fn rejects_empty() {
assert!("".parse::<u32>().is_err());
}
}
Best Practices
- Use #[test] + assert_eq!/assert! for unit tests
- Put integration tests in tests/ for public API coverage
- Run doctests in CI; they rot silently
- Gate coverage at 80%+ with tarpaulin thresholds
- Use nextest for fast feedback on large workspaces
Capabilities
cargo-testing
Run unit, integration, and doc tests.
Parameters:
filter (string): Test name substring filter
nocapture (boolean): Show println output from tests
threads (number): Test thread count
Commands:
cargo test
cargo test my_module::test_name
cargo test -- --nocapture
cargo test --release
cargo test --doc
Examples:
- cargo test
- cargo test my_module::test_name -- --nocapture
- cargo test -- --test-threads=8
nextest-and-coverage
Faster parallel testing and coverage measurement.
Parameters:
outFormat (string): Coverage format: html, xml, json
partition (string): Test partition for sharding
Commands:
cargo nextest run
cargo nextest run --partition count:2/2
cargo tarpaulin --out html
cargo llvm-cov --open
cargo nextest run --fail-fast
Examples:
- cargo nextest run
- cargo tarpaulin --out html
- cargo llvm-cov --open
concurrency-and-vet
Race detection and lints for tests.
Parameters:
features (string): Cargo features to enable
testThreads (integer): Number of parallel test threads via --test-threads.
Commands:
cargo test -- --test-threads=1
RUSTFLAGS='-C target-feature=+crt-static' cargo test
cargo clippy --all-targets -- -D warnings
cargo test --features integration
Examples:
- cargo test -- --test-threads=1
- cargo clippy --all-targets -- -D warnings
- cargo test --features integration
References
1---2name: "cargo-test"3description: "Runs Rust test suites with cargo test, nextest, and coverage tools, including doctests and race condition checks. Use when working with cargo testing, nextest and coverage, concurrency and vet or when the user mentions cargo testing, nextest and coverage, concurrency and vet."4license: "MIT"5compatibility: "Requires cargo, rustflags='-c."6metadata:7 source: https://skillmd.com/skills/opknock/cargo-test8 author: Kdesk9 version: 2.0.010 category: testing11allowed-tools: "Glob Grep Read Bash(RUSTFLAGS='-C:*) Bash(cargo:*)"12---1314Runs Rust test suites with cargo test, nextest, and coverage tools, including doctests and race condition checks.1516## Agentic Workflow: Read -> Reason -> Act (cargo-test)1718You are **cargo-test** (testing/general) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — testing context for `cargo-test`21- Domain: Runs Rust test suites with cargo test, nextest, and coverage tools, including doctests and race condition checks.22- **cargo-testing**: Run unit, integration, and doc tests. — `cargo test`23- **nextest-and-coverage**: Faster parallel testing and coverage measurement. — `cargo nextest run`24- **concurrency-and-vet**: Race detection and lints for tests. — `cargo test -- --test-threads=1`25- Check `knowledge` and `prerequisites: cargo, rustflags='-c`2627### 2. Reason — think for `cargo-test`28- For `cargo-testing`: Run unit, integration, and doc tests. — decide which checks to run29- For `nextest-and-coverage`: Faster parallel testing and coverage measurement. — decide which checks to run30- For `concurrency-and-vet`: Race detection and lints for tests. — decide which checks to run31- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3233### 3. Act — execute with `cargo-test` tools34- Tools: `Glob`, `Grep`, `Read`, `Bash`, `RUSTFLAGS='-C` (see frontmatter `tools`/`allowed-tools`)35- Use `safe_path` for any write; record evidence (paths, checksums)36- Fingerprint: `cargo-test:a78e3336`3738# cargo test3940Test Rust code with unit, integration, and doc tests.4142## What This Skill Does4344- Runs the full test matrix (unit, integration, docs)45- Filters tests by name and shows captured output46- Measures coverage with tarpaulin or llvm-cov47- Speeds up CI with nextest sharding4849## When to Use5051- Verifying changes before merge52- Debugging a single failing test53- Enforcing coverage thresholds5455## Real Commands5657```bash58# Basics59cargo test60cargo test my_module::test_name61cargo test -- --nocapture62cargo test --release63cargo test --doc6465# Nextest66cargo nextest run67cargo nextest run --partition count:2/26869# Coverage70cargo tarpaulin --out html71cargo llvm-cov --open7273# Quality74cargo clippy --all-targets -- -D warnings75```7677## Sample Test7879```rust80#[cfg(test)]81mod tests {82 #[test]83 fn parses_numbers() {84 assert_eq!("42".parse::<u32>().unwrap(), 42);85 }8687 #[test]88 fn rejects_empty() {89 assert!("".parse::<u32>().is_err());90 }91}92```9394## Best Practices9596- Use #[test] + assert_eq!/assert! for unit tests97- Put integration tests in tests/ for public API coverage98- Run doctests in CI; they rot silently99- Gate coverage at 80%+ with tarpaulin thresholds100- Use nextest for fast feedback on large workspaces101102## Capabilities103104### cargo-testing105Run unit, integration, and doc tests.106107**Parameters:**108- `filter` (string): Test name substring filter109- `nocapture` (boolean): Show println output from tests110- `threads` (number): Test thread count111112**Commands:**113- `cargo test`114- `cargo test my_module::test_name`115- `cargo test -- --nocapture`116- `cargo test --release`117- `cargo test --doc`118119**Examples:**120- cargo test121- cargo test my_module::test_name -- --nocapture122- cargo test -- --test-threads=8123124### nextest-and-coverage125Faster parallel testing and coverage measurement.126127**Parameters:**128- `outFormat` (string): Coverage format: html, xml, json129- `partition` (string): Test partition for sharding130131**Commands:**132- `cargo nextest run`133- `cargo nextest run --partition count:2/2`134- `cargo tarpaulin --out html`135- `cargo llvm-cov --open`136- `cargo nextest run --fail-fast`137138**Examples:**139- cargo nextest run140- cargo tarpaulin --out html141- cargo llvm-cov --open142143### concurrency-and-vet144Race detection and lints for tests.145146**Parameters:**147- `features` (string): Cargo features to enable148- `testThreads` (integer): Number of parallel test threads via --test-threads.149150**Commands:**151- `cargo test -- --test-threads=1`152- `RUSTFLAGS='-C target-feature=+crt-static' cargo test`153- `cargo clippy --all-targets -- -D warnings`154- `cargo test --features integration`155156**Examples:**157- cargo test -- --test-threads=1158- cargo clippy --all-targets -- -D warnings159- cargo test --features integration160161## References162- [cargo test Reference](https://doc.rust-lang.org/cargo/commands/cargo-test.html)163- [Nextest Documentation](https://nexte.st/)164- [cargo-tarpaulin](https://github.com/xd009642/tarpaulin)