Reputation: 10329
Is it possible to programmatically skip some tests based on runtime information? For example, I would like cargo test
to emit something like
test my_test ... skipped
instead of
test my_test ... ok
when cond()
is evaluated to false
in the following test:
#[test]
fn my_test() {
if !cond() {
// Mark the test as skipped. How?
return;
}
// The actual test that works only when cond() returns true.
}
In other words, I am looking for a Rust alternative of unittest.skipTest()
in Python (more information).
Upvotes: 25
Views: 2938
Reputation: 15559
There is nothing built in for this; tests only succeed or fail.
The built in test runner is very minimal.
Upvotes: 16