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).
OK, so the @Ignore annotation is good for marking that a test case shouldn't be run. However, sometimes I want to ignore a test based on runtime information. An example might be if I have a concurrency test that needs to be run on a machine with a certain number of cores.
Now, update TestJunit in C:\>JUNIT_WORKSPACE to ignore all test cases. Add @Ignore at class level. Compile the test case using javac. Now run the Test Runner, which will not run any test case defined in the provided Test Case class.
There is nothing built in for this; tests only succeed or fail.
The built in test runner is very minimal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With