How to conditionally skip tests based on runtime information?

Is it possible to programmatically skip some tests based on runtime information? For example, I would like to cargo testgive out something like

test my_test ... skipped

instead

test my_test ... ok

when cond()evaluated to falsein 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'm looking for an alternative to Rust unittest.skipTest()in Python ( more info ).

+6
source share
1 answer

Nothing has been created for this; tests only succeed or fail.

The built-in test runner is very minimal.

+5
source

Source: https://habr.com/ru/post/1016694/


All Articles