cargo-nextest
$ cargo-nextest 社区开源 低风险cargo-nextest 在独立子进程中执行每个 Rust 测试,提升速度并隔离段错误与全局状态污染。支持 cargo nextest list --message-format json 结构化列出测试、实验性 libtest-json 运行输出以及 JUnit XML 报告。
brew install cargo-nextest 与 cargo 及本地 Rust 工作区紧密耦合的测试运行器;Agent 应直接在工作区调用 cargo nextest。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持 list --message-format json、强大的 -E 过滤表达式与 --color never,但 run --message-format libtest-json 仍需设置 NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1。
cargo nextest list --message-format jsonfor test discovery- Experimental JSON test-run output gated behind
NEXTEST_EXPERIMENTAL_LIBTEST_JSON=1
单测试进程隔离避免测试间状态污染;纯本地执行且不涉及任何凭证。
- Process-per-test isolation limits crash blast radius
可通过 Homebrew、cargo-binstall 及 GitHub 预编译包在 macOS、Linux 与 Windows 安装,需本地具备 Rust 工具链。
- Available via
brew install cargo-nextestandcargo install
在大型工作区上明显快于 cargo test,内置重试、慢测试告警与过滤表达式。
- Parallel per-test scheduling and built-in retry/JUnit support
由 nextest-rs 积极维护,在 Rust 生态中获得广泛采用。
- Standard alternative test runner in Rust CI
nexte.st 文档详尽,各子命令 --help 信息完善。
- Structured online docs and filterset reference
安全边界、鉴权与放权指南
无需凭证;直接运行本地 Cargo 工作区编译出的测试二进制。
Apache-2.0 / MIT 双协议开源工具,完全免费。
# 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 高频安全命令配方
只读查询(安全推荐)
cargo nextest list --message-format json --color never
以结构化 JSON 枚举所有测试二进制与用例名称,不实际运行测试。
cargo nextest run --color never -E 'test(parser)'
利用 nextest 过滤表达式(-E)仅运行匹配的用例并保持输出整洁。
受控写入与预演
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。