CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

cargo-nextest

$ cargo-nextest 社区开源 低风险
nextest-rs · 代码托管与研发协同 · Apache-2.0 OR MIT · macos / linux / windows

cargo-nextest 在独立子进程中执行每个 Rust 测试,提升速度并隔离段错误与全局状态污染。支持 cargo nextest list --message-format json 结构化列出测试、实验性 libtest-json 运行输出以及 JUnit XML 报告。

FCRS-1.0 综合评分
87 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install cargo-nextest
CLI vs MCP 选型建议 仅 CLI 可用

与 cargo 及本地 Rust 工作区紧密耦合的测试运行器;Agent 应直接在工作区调用 cargo nextest。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

支持 list --message-format json、强大的 -E 过滤表达式与 --color never,但 run --message-format libtest-json 仍需设置 NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1。

  • cargo nextest list --message-format json for test discovery
  • Experimental JSON test-run output gated behind NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1
安全与权限边界 22 / 25

单测试进程隔离避免测试间状态污染;纯本地执行且不涉及任何凭证。

  • Process-per-test isolation limits crash blast radius
安装与运行摩擦 13 / 15

可通过 Homebrew、cargo-binstall 及 GitHub 预编译包在 macOS、Linux 与 Windows 安装,需本地具备 Rust 工具链。

  • Available via brew install cargo-nextest and cargo install
能力覆盖与边际价值 14 / 15

在大型工作区上明显快于 cargo test,内置重试、慢测试告警与过滤表达式。

  • Parallel per-test scheduling and built-in retry/JUnit support
维护与来源背书 9 / 10

由 nextest-rs 积极维护,在 Rust 生态中获得广泛采用。

  • Standard alternative test runner in Rust CI
文档与可验证性 8 / 10

nexte.st 文档详尽,各子命令 --help 信息完善。

  • Structured online docs and filterset reference

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需凭证;直接运行本地 Cargo 工作区编译出的测试二进制。

潜在副作用
只读查询 本地写入
费用与配额提示

Apache-2.0 / MIT 双协议开源工具,完全免费。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# cargo-nextest Agent Rules
- Use `cargo nextest list --message-format json` to inspect test names before filtering with `-E`.
- Pass `--color never` and `--no-fail-fast` when collecting full failure diagnostics.
- Remember that `cargo nextest` does not run Rust doctests (`cargo test --doc` is separate).

Agent 高频安全命令配方

只读查询(安全推荐)

以 JSON 列出工作区全部测试
cargo nextest list --message-format json --color never

以结构化 JSON 枚举所有测试二进制与用例名称,不实际运行测试。

使用无颜色输出运行过滤后的测试
cargo nextest run --color never -E 'test(parser)'

利用 nextest 过滤表达式(-E)仅运行匹配的用例并保持输出整洁。

受控写入与预演

使用 CI 配置档案运行并生成 JUnit XML
cargo nextest run --profile ci --color never

按工作区 .config/nextest.toml 中的 CI 配置执行测试并输出 JUnit XML 产物。

核心优势

  • + 每个测试在独立子进程运行,能干净捕获崩溃与超时。
  • + cargo nextest list --message-format json 配合 -E 过滤表达式便于精确执行目标测试。
  • + 支持通过 .config/nextest.toml 原生配置 JUnit XML 与失败重试。

注意事项与踩坑点

  • ! 运行(run)阶段的 JSON 输出(--message-format libtest-json)目前仍需显式开启 NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1。
  • ! 不运行 Rust 文档测试(doctest),需要时需单独执行 cargo test --doc。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI