Skip to main content

add_failure

Macro add_failure 

Source
macro_rules! add_failure {
    ($($message:expr),+ $(,)?) => { ... };
    () => { ... };
}
Expand description

Generates a failure marking the test as failed but continue execution.

This is a not-fatal failure. The test continues execution even after the macro execution.

This can only be invoked inside tests with the gtest attribute. The failure must be generated in the same thread as that running the test itself.

use googletest::prelude::*;

#[gtest]
fn should_fail_but_not_abort() {
    add_failure!();
}

One may include formatted arguments in the failure message:

use googletest::prelude::*;

#[gtest]
fn should_fail_but_not_abort() {
    add_failure!("I am just a fake test: {}", "a fake test indeed");
}