googletest icon indicating copy to clipboard operation
googletest copied to clipboard

Do not run test suite if SetUpTestSuite fails

Open HammerFall42 opened this issue 3 years ago • 2 comments

In the latest 1.11.0 release failed SetUpTestSuite is not ignored anymore, but tests from the suite are still run after it fails.

It is common for tests to rely on something done in SetUpTestSuite, so running tests after it fails causes them to fail anyway or to finish program with segmentation fault. For example:

static void SetUpTestSuite() {
    ...
    ASSERT_EQ(SUCCESS_MACRO, someInitFunc()); //fails
    m_ptr = malloc(size);
    ...
  }
TEST_F(SomeTestSuite, AfterFailedSetup) {
    ...
    m_ptr[N] = ...; //causes segmentation fault
    ...
}

It would be nice to have an opportunity to mark whole test suite as failed if SetUpTestSuite fails and do not run tests from this suite.

HammerFall42 avatar Apr 21 '22 13:04 HammerFall42

Also it'll be cool to support GTEST_SKIP in SetUpTestSuit!

SherAndrei avatar Jun 02 '23 19:06 SherAndrei

It seems that your case is already fixed upstream: https://godbolt.org/z/xbnGMcMfv

SherAndrei avatar Jun 07 '23 20:06 SherAndrei