Cargo-nextest: 比 cargo test 快 3 倍,每个测试隔离,一流的 CI 支持

Hacker News Top 工具

摘要

Cargo-nextest 是 Rust 的下一代测试运行器,提供高达 3 倍的测试执行速度、每个测试的隔离以及一流的 CI 支持。

暂无内容
查看原文
查看缓存全文

缓存时间: 2026/07/09 07:35

# 主页 来源:https://nexte.st/ ## 下一代 Rust 测试运行器 相比 `cargo test` 快 3 倍,拥有现代界面、每个测试独立隔离以及一流的 CI 支持。 - **简洁美观的用户界面** —— 一眼看清哪些测试通过或失败。运行测试 (https://nexte.st/docs/running/) - **比 cargo test 快 3 倍** —— Nextest 采用现代执行模型 (https://nexte.st/docs/design/how-it-works/) 实现更快、更可靠的测试运行。基准测试 (https://nexte.st/docs/benchmarks/) - **强大的测试选择** —— 使用复杂的表达式语言 (https://nexte.st/docs/filtersets/) 精确选择所需测试。可按名称、二进制文件、平台或任意组合过滤。过滤器集 (https://nexte.st/docs/filtersets/) - **识别行为异常的测试** —— 将测试视为牲畜而非宠物。检测并处理慢测试 (https://nexte.st/docs/features/slow-tests/)。通过压力测试 (https://nexte.st/docs/features/stress-tests/) 多次循环运行测试。慢测试与超时 (https://nexte.st/docs/features/slow-tests/) - **按测试自定义设置** —— 自动重试 (https://nexte.st/docs/features/retries/) 某些测试、标记为重负载 (https://nexte.st/docs/configuration/threads-required/)、串行运行 (https://nexte.st/docs/configuration/test-groups/) 等等。按测试设置 (https://nexte.st/docs/configuration/per-test-overrides/) - **记录、回放与重跑** —— 记录 (https://nexte.st/docs/features/record-replay-rerun/) 每次测试运行。在本地回放 (https://nexte.st/docs/features/record-replay-rerun/replay/) CI 运行结果。重跑 (https://nexte.st/docs/features/record-replay-rerun/rerun/) 失败的测试。导出 Perfetto 追踪 (https://nexte.st/docs/features/record-replay-rerun/perfetto-chrome-traces/) 进行深度分析。记录、回放与重跑 (https://nexte.st/docs/features/record-replay-rerun/) - **专为 CI 设计** —— 归档 (https://nexte.st/docs/ci-features/archiving/) 和分区 (https://nexte.st/docs/ci-features/partitioning/) 测试以跨多个 worker 运行,导出 JUnit XML (https://nexte.st/docs/machine-readable/junit/),并使用配置文件 (https://nexte.st/docs/configuration/#profiles) 适应不同环境。配置配置文件 (https://nexte.st/docs/configuration/#profiles) - **设置脚本** —— 在每个测试作用域下运行设置脚本 (https://nexte.st/docs/configuration/setup-scripts/),初始化数据库、启动服务、准备测试夹具。设置脚本 (https://nexte.st/docs/configuration/setup-scripts/) - **丰富的工具生态** —— 收集测试覆盖率 (https://nexte.st/docs/integrations/test-coverage/),进行突变测试 (https://nexte.st/docs/integrations/cargo-mutants/),启动调试器 (https://nexte.st/docs/integrations/debuggers-tracers/),通过 DTrace 和 bpftrace 探针 (https://nexte.st/docs/integrations/usdt/) 观察系统行为。集成 (https://nexte.st/docs/integrations/) - **跨平台** —— 运行于 Linux、Mac、Windows 及其他类 Unix 系统。可下载二进制文件或从源码构建 (https://nexte.st/docs/installation/from-source/)。预构建二进制文件 (https://nexte.st/docs/installation/pre-built-binaries/) - **开源,广泛信赖** —— 为各种规模的 Rust 开发提供动力,从独立开源项目到全球最大科技公司。许可证 (Apache 2.0) (https://github.com/nextest-rs/nextest/blob/main/LICENSE-APACHE) - **最先进,用心打造** —— Nextest 将基础设施级可靠性 (https://nexte.st/docs/design/why-process-per-test/) 引入测试运行器,并用心 (https://nexte.st/docs/design/architecture/runner-loop/) 关注每一个细节。在 GitHub 上赞助 (https://github.com/sponsors/sunshowers) ## 快速开始¶ (https://nexte.st/#quick-start) 使用预构建二进制文件 (https://nexte.st/docs/installation/pre-built-binaries/) 安装 cargo-nextest,然后运行: 注意 由于稳定 Rust 的限制,文档测试目前不受支持 (https://github.com/nextest-rs/nextest/issues/16)。此时请使用 `cargo test --doc` 在单独的步骤中运行文档测试。

相似文章

Cargo 的调度器能否改进?

Lobsters Hottest

本文通过分析 Rust 构建任务的基准测试来研究 Cargo 调度器的行为,并探讨替代调度算法。

Cargo-Geiger

Hacker News Top

cargo-geiger 是一个 Rust cargo 插件,用于列出 crate 及其依赖中不安全代码使用的统计信息,为审计提供输入。

Cargo 的愿景

Lobsters Hottest

一篇博客文章,提出了改进 Cargo 的愿景,涵盖依赖管理、构建性能、适应性和维护等工作流程,并邀请社区提供意见。