diff options
author | durandal <durandal@google.com> | 2018-10-23 19:31:17 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2018-10-24 15:26:16 (GMT) |
commit | 59f90a338bce2376b540ee239cf4e269bf6d68ad (patch) | |
tree | 5111348d2ecf366d8560e992a8976cd40e66d69c | |
parent | 3bb00b7ead35ca3a9b5817ce1ab78050fe6be0e3 (diff) | |
download | googletest-59f90a338bce2376b540ee239cf4e269bf6d68ad.zip googletest-59f90a338bce2376b540ee239cf4e269bf6d68ad.tar.gz googletest-59f90a338bce2376b540ee239cf4e269bf6d68ad.tar.bz2 |
Googletest export
Honor GTEST_SKIP() in SetUp().
PiperOrigin-RevId: 218387359
-rw-r--r-- | googletest/src/gtest.cc | 10 | ||||
-rw-r--r-- | googletest/test/gtest_skip_test.cc | 17 |
2 files changed, 23 insertions, 4 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 4a9c381..332b3e9 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2520,8 +2520,9 @@ void Test::Run() { internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()"); - // We will run the test only if SetUp() was successful. - if (!HasFatalFailure()) { + // We will run the test only if SetUp() was successful and didn't call + // GTEST_SKIP(). + if (!HasFatalFailure() && !IsSkipped()) { impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( this, &Test::TestBody, "the test body"); @@ -2698,9 +2699,10 @@ void TestInfo::Run() { factory_, &internal::TestFactoryBase::CreateTest, "the test fixture's constructor"); - // Runs the test if the constructor didn't generate a fatal failure. + // Runs the test if the constructor didn't generate a fatal failure or invoke + // GTEST_SKIP(). // Note that the object will not be null - if (!Test::HasFatalFailure()) { + if (!Test::HasFatalFailure() && !Test::IsSkipped()) { // This doesn't throw as all user code that can throw are wrapped into // exception handling code. test->Run(); diff --git a/googletest/test/gtest_skip_test.cc b/googletest/test/gtest_skip_test.cc index ee81093..717e105 100644 --- a/googletest/test/gtest_skip_test.cc +++ b/googletest/test/gtest_skip_test.cc @@ -32,7 +32,24 @@ #include "gtest/gtest.h" +using ::testing::Test; + TEST(SkipTest, DoesSkip) { GTEST_SKIP(); EXPECT_EQ(0, 1); } + +class Fixture : public Test { + protected: + void SetUp() override { + GTEST_SKIP() << "skipping all tests for this fixture"; + } +}; + +TEST_F(Fixture, SkipsOneTest) { + EXPECT_EQ(5, 7); +} + +TEST_F(Fixture, SkipsAnotherTest) { + EXPECT_EQ(99, 100); +} |