如何根据运行时信息有条件地跳过测试?

s3r*_*vac 7 rust

是否有可能以编程方式跳过某些基于运行时信息的测试?例如,我想cargo test发出类似的东西

test my_test ... skipped
Run Code Online (Sandbox Code Playgroud)

代替

test my_test ... ok
Run Code Online (Sandbox Code Playgroud)

何时在以下测试中cond()评估false:

#[test]
fn my_test() {
    if !cond() {
        // Mark the test as skipped. How?
        return;
    }

    // The actual test that works only when cond() returns true.
}
Run Code Online (Sandbox Code Playgroud)

换句话说,我正在寻找unittest.skipTest()Python中的Rust替代品(更多信息).

Ste*_*nik 6

没有内置的东西; 测试只有成功或失败.

内置的测试运行器非常小.