-2

I have a test for Google Test Framework that is failing without any further explanation, meaning that the test suite is not crashing but is correcly ending its execution printing:

[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:

with the name of the failed test.

The question is: when can a test in Google Test Framework fail? I only know about missing EXPECT_CALL and wrong ASSERT_TRUE/ASSERT_FALSE, but they all should provide a better explanation in the standard output.

Is there anything else that can make a test fail?

nyarlathotep108
  • 5,275
  • 2
  • 26
  • 64
  • 1
    How about unexpected exception thrown? – user7860670 Sep 11 '17 at 16:38
  • @VTT furtunately, I can exclude this case because our code doesn't use exceptions at all, due to OS restrictions. – nyarlathotep108 Sep 11 '17 at 16:40
  • But google test code does use them anyway. – user7860670 Sep 11 '17 at 16:42
  • In **above** report, you should have detail of each test. – Jarod42 Sep 11 '17 at 16:48
  • @Jarod42 I have it. I mean, the report is correctly listing the failing test, but is not telling me the reason why the test is failing. Since I know both EXPECT_CALL and ASSERT are more verbose than what I'm getting in the output, my question is: can a test fail also for other reasons? – nyarlathotep108 Sep 11 '17 at 16:52
  • @VTT do you mean that I should run the `RUN_ALL_TESTS` macro inside a `try`-`catch` block and print out everything that is catched? – nyarlathotep108 Sep 11 '17 at 17:03
  • I think you should just debug failing test and figure out what exactly fails. – user7860670 Sep 11 '17 at 17:09
  • Please produce a [mcve]. It's possible to do all kinds of things in GoogleTest, including extending the framework, that could lead to this sort of behavior. Otherwise we cannot tell you. – AndyG Sep 11 '17 at 18:03

1 Answers1

0

A test can also fail if an EXPECT_CALL macro is completely missing for a mocked function if the mocked class is wrapped with the StrictMock<> template class and that function is going to be called in during the test execution.

nyarlathotep108
  • 5,275
  • 2
  • 26
  • 64