有没有一种方法只运行集成测试而不运行单元测试?
我尝试过:
cargo test --tests
:同时运行单元测试和集成测试
cargo test --test test_name
:只运行指定的一个测试
目前是否无法仅运行集成测试或者我漏掉了些什么?
有没有一种方法只运行集成测试而不运行单元测试?
我尝试过:
cargo test --tests
:同时运行单元测试和集成测试
cargo test --test test_name
:只运行指定的一个测试
目前是否无法仅运行集成测试或者我漏掉了些什么?
您可以通过以下方式仅运行集成测试:
cargo test --test '*'
请注意,只有'*'
可用;*
和"*"
都不能使用。cargo test --test *
是有效的。 - RequireKeyscargo test --test *
、cargo test --test '*'
或 cargo test --test "*"
来运行集成测试。它们都会产生相同的结果。 - Saurabh'*'
和"*"
是相同的,而*
(通配符)几乎肯定不会起作用。 - undefined#[ignore]
注释来标记一个测试。否则,使用特定的命名方法对测试进行命名,以便您可以按名称过滤它们。Cargo.toml
清单中的目标选项来控制在使用--tests
时运行什么。Cargo参考页面。cargo test --test integration_tests 'intergration_test_method'
cargo test --test integration_tests 'intergration_test_method' -- --nocapture
cargo test pattern
。 - Dimitris Fasarakis Hilliard