How can I expect multiple failures in google test? I use this when testing that asserts happen in my code under test. Because these asserts are not fatal, multiple can happen.
The following testcase reproduces this:
void failTwice()
{
EXPECT_TRUE(false) << "fail first time";
EXPECT_TRUE(false) << "fail second time";
}
TEST_F(FailureTest, testMultipleFails)
{
EXPECT_NONFATAL_FAILURE(failTwice(), "time");
}
This produces the following output:
gtest/src/gtest.cc:657: Failure
Expected: 1 non-fatal failure
Actual: 2 failures
FailureTest.h:20: Non-fatal failure:
Value of: false
Actual: false
Expected: true
fail first time
FailureTest.h:20: Non-fatal failure:
Value of: false
Actual: false
Expected: true
fail second time
The problem is this: Expected: 1 non-fatal failure
How can I tell google test to expect multiple failures?
EXPECT
s. – AbleEXPECT_NONFATAL_FAILURE()
should get in order to pass? – Able