知识卡片

操作参考卡 · 6075.d.14 · 生成模型:未记录

筛选或略过测试

理解等级:中级

cargo test 片段 选择名称含该片段的用例,模块路径也参与匹配。用于标明昂贵用例的 #[ignore] 会使其在日常测试中略过。cargo test -- --ignored 只运行标记忽略的用例,--include-ignored 同时纳入普通和忽略用例。

相关卡片 [[测试参数与输出捕获]]

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 编写自动化测试 Running a Subset of Tests by Name · 查看原书依据

      By controlling which tests run, you can make sure your cargo test results will be returned quickly. When you’re at a point where it makes sense to check the results of the ignored tests and you have time to wait for the results, you can run cargo test -- --ignored instead. If you want to run all tests whether they’re ignored or not, you can run cargo test -- --include-ignored.

    参考来源

    - 位置:《The Rust Programming Language(第2版)》第11章 编写自动化测试(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c11.xhtml`,块 0184) - 结论依据:原文用两种运行器选项区分只跑标记忽略的用例与同时包含两类用例。 - 原始内容:By controlling which tests run, you can make sure your cargo test results will be returned quickly. When you’re at a point where it makes sense to check the results of the ignored tests and you have time to wait for the results, you can run cargo test -- --ignored instead. If you want to run all tests whether they’re ignored or not, you can run cargo test -- --include-ignored.