1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages.zh/common/cargo-test.md
Lena 554fd30c20
cargo, cargo-{build,check,doc,run,test}: add option placeholders (#15895)
Co-authored-by: Darío Hereñú <magallania@gmail.com>
2025-03-15 23:28:32 +02:00

678 B

cargo test

执行 Rust 包的单元测试和集成测试。 更多信息:https://doc.rust-lang.org/cargo/commands/cargo-test.html.

  • 仅运行包含特定字符串在其名称中的测试:

cargo {{[t|test]}} {{测试名称}}

  • 设置并行运行测试用例的数量:

cargo {{[t|test]}} -- --test-threads {{数量}}

  • 在 release 模式下测试构建,启用优化:

cargo {{[t|test]}} {{[-r|--release]}}

  • 测试工作区中的所有包:

cargo {{[t|test]}} --workspace

  • 为特定包运行测试:

cargo {{[t|test]}} {{[-p|--package]}} {{包名}}

  • 运行测试时不隐藏测试执行的输出:

cargo {{[t|test]}} -- --nocapture