
cargo-nextest
cargo-nextest: fast Rust test runner with parallel execution and advanced filtering. Use when running tests, setting up CI, or diagnosing flaky/slow tests.
- Installs
- 97
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/laurigates/claude-plugins --skill cargo-nextest- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads cargo-nextest automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
cargo-nextest - Next-Generation Test Runner
cargo-nextest is a faster, more reliable test runner for Rust that executes each test in its own process for better isolation and parallel performance.
When to Use This Skill
| Use this skill when... | Use sibling skill instead when... |
|---|---|
| Running tests in parallel with process isolation | Measuring code coverage -- use cargo-llvm-cov |
| Filtering tests by package, name, or pattern | Linting test code style -- use clippy-advanced |
| Setting up flaky-test retries in CI | Auditing unused test deps -- use cargo-machete |
| Optimizing test runtime via partitioning | Authoring tests / async patterns -- use rust-development |
Installation
# Install cargo-nextest
cargo install cargo-nextest --locked
# Verify installation
cargo nextest --version
Basic Usage
# Run all tests with nextest
cargo nextest run
# Run specific test
cargo nextest run test_name
# Run tests in specific package
cargo nextest run -p package_name
# Run with verbose output
cargo nextest run --verbose
# Run ignored tests
cargo nextest run -- --ignored
# Run all tests including ignored
cargo nextest run -- --include-ignored
Configuration File
Create .config/nextest.toml in your project root:
[profile.default]
# Number of retries for flaky tests
retries = 0
# Test threads (default: number of logical CPUs)
test-threads = 8
# Fail fast - stop on first failure
fail-fast = false
# Show output for passing tests
success-output = "never" # never, immediate, final, immediate-final
# Show output for failing tests
failure-output = "immediate" # never, immediate, final, immediate-final
[profile.ci]
# CI-specific configuration
retries = 2
fail-fast = true
success-output = "never"
failure-output = "immediate-final"
# Slow test timeout
slow-timeout = { period = "60s", terminate-after = 2 }
[profile.ci.junit]
# JUnit XML output for CI
path = "target/nextest/ci/junit.xml"
Test Filtering with Expression Language
# Run tests matching pattern
cargo nextest run -E 'test(auth)'
# Run tests in specific binary
cargo nextest run -E 'binary(my_app)'
# Run tests in specific package
cargo nextest run -E 'package(my_crate)'
# Complex expressions with operators
cargo nextest run -E 'test(auth) and not test(slow)'
# Run all integration tests
cargo nextest run -E 'kind(test)'
# Run only unit tests in library
cargo nextest run -E 'kind(lib) and test(/)'
Expression Operators
test(pattern)- Match test name (regex)binary(pattern)- Match binary namepackage(pattern)- Match package namekind(type)- Match test kind (lib, bin, test, bench, example)platform(os)- Match target platformnot expr- Logical NOTexpr and expr- Logical ANDexpr or expr- Logical OR
Parallel Execution
Nextest runs each test in its own process by default, providing:
- Better isolation - Tests cannot interfere with each other
- True parallelism - No global state conflicts
- Fault isolation - One test crash doesn't affect others
- Better resource management - Each test has clean environment
# Control parallelism
cargo nextest run --test-threads 4
# Single-threaded execution
cargo nextest run --test-threads 1
# Use all available cores
cargo nextest run --test-threads 0
Output Formats
# Human-readable output (default)
cargo nextest run
# JSON output for programmatic parsing
cargo nextest run --message-format json
# JSON with test output
cargo nextest run --message-format json-pretty
# Generate JUnit XML for CI
cargo nextest run --profile ci
# Combine with cargo-llvm-cov for coverage
cargo llvm-cov nextest --html
Flaky Test Management
# In .config/nextest.toml
[profile.default]
# Retry flaky tests automatically
retries = 3
# Detect tests that pass on retry
[profile.default.overrides]
filter = 'test(flaky_)'
retries = 5
# Run with retries
cargo nextest run --retries 3
# Show retry statistics
cargo nextest run --retries 3 --failure-output immediate-final
GitHub Actions Integration
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install nextest
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Run tests
run: cargo nextest run --profile ci --all-features
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: target/nextest/ci/junit.xml
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/nextest/ci/junit.xml
Advanced Configuration
# .config/nextest.toml
[profile.default]
# Timeout for slow tests
slow-timeout = { period = "30s", terminate-after = 3 }
# Test groups for resource management
[test-groups.database]
max-threads = 1 # Serialize database tests
[profile.default.overrides]
filter = 'test(db_)'
test-group = 'database'
# Platform-specific overrides
[[profile.default.overrides]]
platform = 'x86_64-pc-windows-msvc'
slow-timeout = { period = "60s" }
Doctests Limitation
Important: nextest does not support doctests. Use cargo test for doctests:
# Run doctests separately
cargo test --doc
# Run both nextest and doctests in CI
cargo nextest run && cargo test --doc
Workspace Configuration
# In workspace root .config/nextest.toml
[profile.default]
default-filter = 'all()'
# Per-package overrides
[[profile.default.overrides]]
filter = 'package(slow_tests)'
test-threads = 1
slow-timeout = { period = "120s" }
Comparison with cargo test
| Feature | cargo test | cargo nextest |
|---|---|---|
| Execution model | In-process | Per-test process |
| Parallelism | Thread-based | Process-based |
| Test isolation | Shared state | Complete isolation |
| Output format | Limited | Rich (JSON, JUnit) |
| Flaky test handling | Manual | Built-in retries |
| Doctests | Supported | Not supported |
| Performance | Good | Excellent |
Best Practices
-
Use profiles for different environments:
defaultfor local developmentcifor continuous integrationcoveragefor coverage analysis
-
Configure flaky test detection:
[profile.default] retries = 2 -
Group resource-intensive tests:
[test-groups.expensive] max-threads = 2 -
Set appropriate timeouts:
[profile.default] slow-timeout = { period = "60s", terminate-after = 2 } -
Use expression filters effectively:
# Run fast tests during development cargo nextest run -E 'not test(slow_)' -
Always run doctests separately in CI:
- run: cargo nextest run --all-features - run: cargo test --doc --all-features
Troubleshooting
Tests timeout too quickly:
[profile.default]
slow-timeout = { period = "120s", terminate-after = 3 }
Too much parallel execution:
cargo nextest run --test-threads 4
Need test output for debugging:
cargo nextest run --success-output immediate --failure-output immediate
Flaky tests in CI:
[profile.ci]
retries = 3
failure-output = "immediate-final"
References
FAQ
What does the cargo-nextest skill do?
cargo-nextest: fast Rust test runner with parallel execution and advanced filtering. Use when running tests, setting up CI, or diagnosing flaky/slow tests.
How do I install cargo-nextest?
Run npx skills add https://github.com/laurigates/claude-plugins --skill cargo-nextest in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/cargo-nextest/ (personal) or .claude/skills/cargo-nextest/ (project).
Which AI agents can use cargo-nextest?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is cargo-nextest safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains cargo-nextest?
It is published by laurigates in laurigates/claude-plugins. It has 97 recorded installs.
More from laurigates/claude-plugins
python-code-quality
laurigates/claude-plugins
Python code quality with ruff and ty. Use when the user mentions ruff, ty, linting, formatting, type checking, or Python code style.
python-testing
laurigates/claude-plugins
Python testing with pytest, coverage, fixtures, and mocking. Use when the user mentions pytest, unit tests, coverage, fixtures, mocking, or writing Python tests.
pytest-advanced
laurigates/claude-plugins
Advanced pytest: fixtures, markers, parametrization, parallel execution. Use when implementing test infrastructure, writing fixtures, or running with coverage.
uv-workspaces
laurigates/claude-plugins
Manage multi-package Python projects with uv workspaces. Use when the user mentions uv workspaces, Python monorepo, shared lockfiles, or member dependencies.
uv-project-management
laurigates/claude-plugins
Python project setup, deps, and lockfiles with uv. Use when the user mentions uv, creating Python projects, managing dependencies, lockfiles, or pyproject.toml.
Popular testing & qa skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
grilling
mattpocock/skills
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
migrate-to-shoehorn
mattpocock/skills
Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.
run-train
lllllllama/rigorpilot-skills
Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.
test-driven-development
obra/superpowers
Use when implementing any feature or bugfix, before writing implementation code
finishing-a-development-branch
obra/superpowers
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work