Skip to main content

skip_when

Macro skip_when 

Source
macro_rules! skip_when {
    ($cond:expr, $reason:expr) => { ... };
}
Available on crate feature std only.
Expand description

Conditionally skips a test at runtime with a reason.

When the condition is true, prints a sentinel line and returns early. The cargo-behave CLI detects the sentinel and reclassifies the test as Skipped.

ยงExamples

use behave::prelude::*;

fn demo() -> Result<(), behave::MatchError> {
    skip_when!(cfg!(windows), "only runs on unix");
    expect!(1 + 1).to_equal(2)?;
    Ok(())
}

assert!(demo().is_ok());