Googletest export
Honor GTEST_SKIP() in SetUp(). PiperOrigin-RevId: 218387359
This commit is contained in:
parent
3bb00b7ead
commit
59f90a338b
@ -2520,8 +2520,9 @@ void Test::Run() {
|
|||||||
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
|
||||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||||
internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
|
internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
|
||||||
// We will run the test only if SetUp() was successful.
|
// We will run the test only if SetUp() was successful and didn't call
|
||||||
if (!HasFatalFailure()) {
|
// GTEST_SKIP().
|
||||||
|
if (!HasFatalFailure() && !IsSkipped()) {
|
||||||
impl->os_stack_trace_getter()->UponLeavingGTest();
|
impl->os_stack_trace_getter()->UponLeavingGTest();
|
||||||
internal::HandleExceptionsInMethodIfSupported(
|
internal::HandleExceptionsInMethodIfSupported(
|
||||||
this, &Test::TestBody, "the test body");
|
this, &Test::TestBody, "the test body");
|
||||||
@ -2698,9 +2699,10 @@ void TestInfo::Run() {
|
|||||||
factory_, &internal::TestFactoryBase::CreateTest,
|
factory_, &internal::TestFactoryBase::CreateTest,
|
||||||
"the test fixture's constructor");
|
"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
|
// 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
|
// This doesn't throw as all user code that can throw are wrapped into
|
||||||
// exception handling code.
|
// exception handling code.
|
||||||
test->Run();
|
test->Run();
|
||||||
|
@ -32,7 +32,24 @@
|
|||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
using ::testing::Test;
|
||||||
|
|
||||||
TEST(SkipTest, DoesSkip) {
|
TEST(SkipTest, DoesSkip) {
|
||||||
GTEST_SKIP();
|
GTEST_SKIP();
|
||||||
EXPECT_EQ(0, 1);
|
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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user