[英]Unit test timeout in Rust
Is there a way to specify a timeout for a specific unit test in Rust?有没有办法为 Rust 中的特定单元测试指定超时?
The only way to do it so add it to the test case as a hardcoded argument: https://docs.rs/ntest/0.7.2/ntest/index.html这样做的唯一方法是将其作为硬编码参数添加到测试用例中: https://docs.rs/ntest/0.7.2/ntest/index.html
But I wanted to ask if there is a way to provide in the command line as an argument to running test.但我想问是否有办法在命令行中提供作为运行测试的参数。 Something like: cargo test <timeout?>
类似的东西: cargo test <timeout?>
You can get help on the test runner with cargo test -- --help
.您可以使用cargo test -- --help
获得测试运行器的帮助。 In particular you will find:特别是您会发现:
--ensure-time Treat excess of the test execution time limit as
error.
Threshold values for this option can be configured via
`RUST_TEST_TIME_UNIT`, `RUST_TEST_TIME_INTEGRATION`
and
`RUST_TEST_TIME_DOCTEST` environment variables.
Expected format of environment variable is
`VARIABLE=WARN_TIME,CRITICAL_TIME`.
`CRITICAL_TIME` here means the limit that should not
be exceeded by test.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.