pub fn verify_current_test_outcome() -> Result<()>
Expand description

Returns a Result corresponding to the outcome of the currently running test.

This returns Result::Err precisely if the current test has recorded at least one test assertion failure via expect_that!, expect_pred!, or GoogleTestSupport::and_log_failure. It can be used in concert with the ? operator to continue execution of the test conditionally on there not having been any failure yet.

This requires the use of the #[googletest::test] attribute macro.

#[googletest::test]
fn should_fail_and_not_execute_last_assertion() -> Result<()> {
    expect_that!(foo(), eq(2));     // May fail, but will not abort the test.
    expect_that!(bar(), gt(1));     // May fail, but will not abort the test.
    verify_current_test_outcome()?; // Aborts the test if one of the previous assertions failed.
    verify_that!(foo(), gt(0))      // Does not execute if the line above aborts.
}