There are the Test::HasFailure()
, Test::HasNonfatalFailure()
and Test::HasFatalFailure()
functions, that return true
if there was a (fatal/non-fatal) failure. You could use them to check.
TEST_F(test_similarity,are_similar) {
EXPECT_GT(1e-10,norm(im0,im1)); // Note the change to EXPECT
// If test fails save images to disk for comparison:
if(HasFailure()) { // if not in a TEST, use ::testing::Test::HasFailure()
imwrite("im0.png",im0);
imwrite("im1.png",im1);
FAIL(); //We want to fail fatally; use ADD_FAILURE() to fail non-fatally
}
}
See https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#checking-for-failures-in-the-current-test for details.