Googletest export
TestCase->TestSuite refactoring PiperOrigin-RevId: 227702164
This commit is contained in:
@@ -140,8 +140,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
|
||||
|
||||
def testCatchesCxxExceptionsInSetUpTestCase(self):
|
||||
self.assert_('C++ exception with description "Standard C++ exception"'
|
||||
' thrown in SetUpTestCase()'
|
||||
in EX_BINARY_OUTPUT)
|
||||
' thrown in SetUpTestSuite()' in EX_BINARY_OUTPUT)
|
||||
self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() '
|
||||
'called as expected.'
|
||||
in EX_BINARY_OUTPUT)
|
||||
@@ -163,8 +162,7 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
|
||||
|
||||
def testCatchesCxxExceptionsInTearDownTestCase(self):
|
||||
self.assert_('C++ exception with description "Standard C++ exception"'
|
||||
' thrown in TearDownTestCase()'
|
||||
in EX_BINARY_OUTPUT)
|
||||
' thrown in TearDownTestSuite()' in EX_BINARY_OUTPUT)
|
||||
|
||||
def testCatchesCxxExceptionsInSetUp(self):
|
||||
self.assert_('C++ exception with description "Standard C++ exception"'
|
||||
|
||||
@@ -125,6 +125,78 @@ class EventRecordingListener : public TestEventListener {
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
// This listener is using OnTestSuiteStart, OnTestSuiteEnd API
|
||||
class EventRecordingListener2 : public TestEventListener {
|
||||
public:
|
||||
explicit EventRecordingListener2(const char* name) : name_(name) {}
|
||||
|
||||
protected:
|
||||
void OnTestProgramStart(const UnitTest& /*unit_test*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestProgramStart"));
|
||||
}
|
||||
|
||||
void OnTestIterationStart(const UnitTest& /*unit_test*/,
|
||||
int iteration) override {
|
||||
Message message;
|
||||
message << GetFullMethodName("OnTestIterationStart") << "(" << iteration
|
||||
<< ")";
|
||||
g_events->push_back(message.GetString());
|
||||
}
|
||||
|
||||
void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpStart"));
|
||||
}
|
||||
|
||||
void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnEnvironmentsSetUpEnd"));
|
||||
}
|
||||
|
||||
void OnTestSuiteStart(const TestSuite& /*test_suite*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestSuiteStart"));
|
||||
}
|
||||
|
||||
void OnTestStart(const TestInfo& /*test_info*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestStart"));
|
||||
}
|
||||
|
||||
void OnTestPartResult(const TestPartResult& /*test_part_result*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestPartResult"));
|
||||
}
|
||||
|
||||
void OnTestEnd(const TestInfo& /*test_info*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestEnd"));
|
||||
}
|
||||
|
||||
void OnTestSuiteEnd(const TestSuite& /*test_suite*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestSuiteEnd"));
|
||||
}
|
||||
|
||||
void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownStart"));
|
||||
}
|
||||
|
||||
void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnEnvironmentsTearDownEnd"));
|
||||
}
|
||||
|
||||
void OnTestIterationEnd(const UnitTest& /*unit_test*/,
|
||||
int iteration) override {
|
||||
Message message;
|
||||
message << GetFullMethodName("OnTestIterationEnd") << "(" << iteration
|
||||
<< ")";
|
||||
g_events->push_back(message.GetString());
|
||||
}
|
||||
|
||||
void OnTestProgramEnd(const UnitTest& /*unit_test*/) override {
|
||||
g_events->push_back(GetFullMethodName("OnTestProgramEnd"));
|
||||
}
|
||||
|
||||
private:
|
||||
std::string GetFullMethodName(const char* name) { return name_ + "." + name; }
|
||||
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
class EnvironmentInvocationCatcher : public Environment {
|
||||
protected:
|
||||
void SetUp() override { g_events->push_back("Environment::SetUp"); }
|
||||
@@ -165,6 +237,7 @@ TEST_F(ListenerTest, DoesBar) {
|
||||
|
||||
using ::testing::internal::EnvironmentInvocationCatcher;
|
||||
using ::testing::internal::EventRecordingListener;
|
||||
using ::testing::internal::EventRecordingListener2;
|
||||
|
||||
void VerifyResults(const std::vector<std::string>& data,
|
||||
const char* const* expected_data,
|
||||
@@ -199,6 +272,8 @@ int main(int argc, char **argv) {
|
||||
new EventRecordingListener("1st"));
|
||||
UnitTest::GetInstance()->listeners().Append(
|
||||
new EventRecordingListener("2nd"));
|
||||
UnitTest::GetInstance()->listeners().Append(
|
||||
new EventRecordingListener2("3rd"));
|
||||
|
||||
AddGlobalTestEnvironment(new EnvironmentInvocationCatcher);
|
||||
|
||||
@@ -208,88 +283,117 @@ int main(int argc, char **argv) {
|
||||
::testing::GTEST_FLAG(repeat) = 2;
|
||||
int ret_val = RUN_ALL_TESTS();
|
||||
|
||||
const char* const expected_events[] = {
|
||||
"1st.OnTestProgramStart",
|
||||
"2nd.OnTestProgramStart",
|
||||
"1st.OnTestIterationStart(0)",
|
||||
"2nd.OnTestIterationStart(0)",
|
||||
"1st.OnEnvironmentsSetUpStart",
|
||||
"2nd.OnEnvironmentsSetUpStart",
|
||||
"Environment::SetUp",
|
||||
"2nd.OnEnvironmentsSetUpEnd",
|
||||
"1st.OnEnvironmentsSetUpEnd",
|
||||
"1st.OnTestCaseStart",
|
||||
"2nd.OnTestCaseStart",
|
||||
"ListenerTest::SetUpTestCase",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"ListenerTest::TearDownTestCase",
|
||||
"2nd.OnTestCaseEnd",
|
||||
"1st.OnTestCaseEnd",
|
||||
"1st.OnEnvironmentsTearDownStart",
|
||||
"2nd.OnEnvironmentsTearDownStart",
|
||||
"Environment::TearDown",
|
||||
"2nd.OnEnvironmentsTearDownEnd",
|
||||
"1st.OnEnvironmentsTearDownEnd",
|
||||
"2nd.OnTestIterationEnd(0)",
|
||||
"1st.OnTestIterationEnd(0)",
|
||||
"1st.OnTestIterationStart(1)",
|
||||
"2nd.OnTestIterationStart(1)",
|
||||
"1st.OnEnvironmentsSetUpStart",
|
||||
"2nd.OnEnvironmentsSetUpStart",
|
||||
"Environment::SetUp",
|
||||
"2nd.OnEnvironmentsSetUpEnd",
|
||||
"1st.OnEnvironmentsSetUpEnd",
|
||||
"1st.OnTestCaseStart",
|
||||
"2nd.OnTestCaseStart",
|
||||
"ListenerTest::SetUpTestCase",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"ListenerTest::TearDownTestCase",
|
||||
"2nd.OnTestCaseEnd",
|
||||
"1st.OnTestCaseEnd",
|
||||
"1st.OnEnvironmentsTearDownStart",
|
||||
"2nd.OnEnvironmentsTearDownStart",
|
||||
"Environment::TearDown",
|
||||
"2nd.OnEnvironmentsTearDownEnd",
|
||||
"1st.OnEnvironmentsTearDownEnd",
|
||||
"2nd.OnTestIterationEnd(1)",
|
||||
"1st.OnTestIterationEnd(1)",
|
||||
"2nd.OnTestProgramEnd",
|
||||
"1st.OnTestProgramEnd"
|
||||
};
|
||||
const char* const expected_events[] = {"1st.OnTestProgramStart",
|
||||
"2nd.OnTestProgramStart",
|
||||
"3rd.OnTestProgramStart",
|
||||
"1st.OnTestIterationStart(0)",
|
||||
"2nd.OnTestIterationStart(0)",
|
||||
"3rd.OnTestIterationStart(0)",
|
||||
"1st.OnEnvironmentsSetUpStart",
|
||||
"2nd.OnEnvironmentsSetUpStart",
|
||||
"3rd.OnEnvironmentsSetUpStart",
|
||||
"Environment::SetUp",
|
||||
"3rd.OnEnvironmentsSetUpEnd",
|
||||
"2nd.OnEnvironmentsSetUpEnd",
|
||||
"1st.OnEnvironmentsSetUpEnd",
|
||||
"3rd.OnTestSuiteStart",
|
||||
"1st.OnTestCaseStart",
|
||||
"2nd.OnTestCaseStart",
|
||||
"ListenerTest::SetUpTestCase",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"3rd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"3rd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"3rd.OnTestEnd",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"3rd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"3rd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"3rd.OnTestEnd",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"ListenerTest::TearDownTestCase",
|
||||
"3rd.OnTestSuiteEnd",
|
||||
"2nd.OnTestCaseEnd",
|
||||
"1st.OnTestCaseEnd",
|
||||
"1st.OnEnvironmentsTearDownStart",
|
||||
"2nd.OnEnvironmentsTearDownStart",
|
||||
"3rd.OnEnvironmentsTearDownStart",
|
||||
"Environment::TearDown",
|
||||
"3rd.OnEnvironmentsTearDownEnd",
|
||||
"2nd.OnEnvironmentsTearDownEnd",
|
||||
"1st.OnEnvironmentsTearDownEnd",
|
||||
"3rd.OnTestIterationEnd(0)",
|
||||
"2nd.OnTestIterationEnd(0)",
|
||||
"1st.OnTestIterationEnd(0)",
|
||||
"1st.OnTestIterationStart(1)",
|
||||
"2nd.OnTestIterationStart(1)",
|
||||
"3rd.OnTestIterationStart(1)",
|
||||
"1st.OnEnvironmentsSetUpStart",
|
||||
"2nd.OnEnvironmentsSetUpStart",
|
||||
"3rd.OnEnvironmentsSetUpStart",
|
||||
"Environment::SetUp",
|
||||
"3rd.OnEnvironmentsSetUpEnd",
|
||||
"2nd.OnEnvironmentsSetUpEnd",
|
||||
"1st.OnEnvironmentsSetUpEnd",
|
||||
"3rd.OnTestSuiteStart",
|
||||
"1st.OnTestCaseStart",
|
||||
"2nd.OnTestCaseStart",
|
||||
"ListenerTest::SetUpTestCase",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"3rd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"3rd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"3rd.OnTestEnd",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"1st.OnTestStart",
|
||||
"2nd.OnTestStart",
|
||||
"3rd.OnTestStart",
|
||||
"ListenerTest::SetUp",
|
||||
"ListenerTest::* Test Body",
|
||||
"1st.OnTestPartResult",
|
||||
"2nd.OnTestPartResult",
|
||||
"3rd.OnTestPartResult",
|
||||
"ListenerTest::TearDown",
|
||||
"3rd.OnTestEnd",
|
||||
"2nd.OnTestEnd",
|
||||
"1st.OnTestEnd",
|
||||
"ListenerTest::TearDownTestCase",
|
||||
"3rd.OnTestSuiteEnd",
|
||||
"2nd.OnTestCaseEnd",
|
||||
"1st.OnTestCaseEnd",
|
||||
"1st.OnEnvironmentsTearDownStart",
|
||||
"2nd.OnEnvironmentsTearDownStart",
|
||||
"3rd.OnEnvironmentsTearDownStart",
|
||||
"Environment::TearDown",
|
||||
"3rd.OnEnvironmentsTearDownEnd",
|
||||
"2nd.OnEnvironmentsTearDownEnd",
|
||||
"1st.OnEnvironmentsTearDownEnd",
|
||||
"3rd.OnTestIterationEnd(1)",
|
||||
"2nd.OnTestIterationEnd(1)",
|
||||
"1st.OnTestIterationEnd(1)",
|
||||
"3rd.OnTestProgramEnd",
|
||||
"2nd.OnTestProgramEnd",
|
||||
"1st.OnTestProgramEnd"};
|
||||
|
||||
VerifyResults(events,
|
||||
expected_events,
|
||||
sizeof(expected_events)/sizeof(expected_events[0]));
|
||||
|
||||
@@ -12,7 +12,7 @@ Expected equality of these values:
|
||||
3
|
||||
Stack trace: (omitted)
|
||||
|
||||
[0;32m[==========] [mRunning 83 tests from 38 test cases.
|
||||
[0;32m[==========] [mRunning 83 tests from 38 test suites.
|
||||
[0;32m[----------] [mGlobal test environment set-up.
|
||||
FooEnvironment::SetUp() called.
|
||||
BarEnvironment::SetUp() called.
|
||||
@@ -392,26 +392,26 @@ Stack trace: (omitted)
|
||||
[0;32m[ RUN ] [mMixedUpTestCaseTest.ThisShouldFail
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class. However, in test case MixedUpTestCaseTest,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class. However, in test suite MixedUpTestCaseTest,
|
||||
you defined test FirstTestFromNamespaceFoo and test ThisShouldFail
|
||||
using two different test fixture classes. This can happen if
|
||||
the two classes are from different namespaces or translation
|
||||
units and have the same name. You should probably rename one
|
||||
of the classes to put the tests into different test cases.
|
||||
of the classes to put the tests into different test suites.
|
||||
Stack trace: (omitted)
|
||||
|
||||
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFail
|
||||
[0;32m[ RUN ] [mMixedUpTestCaseTest.ThisShouldFailToo
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class. However, in test case MixedUpTestCaseTest,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class. However, in test suite MixedUpTestCaseTest,
|
||||
you defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo
|
||||
using two different test fixture classes. This can happen if
|
||||
the two classes are from different namespaces or translation
|
||||
units and have the same name. You should probably rename one
|
||||
of the classes to put the tests into different test cases.
|
||||
of the classes to put the tests into different test suites.
|
||||
Stack trace: (omitted)
|
||||
|
||||
[0;31m[ FAILED ] [mMixedUpTestCaseTest.ThisShouldFailToo
|
||||
@@ -421,13 +421,13 @@ Stack trace: (omitted)
|
||||
[0;32m[ RUN ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class. However, in test case MixedUpTestCaseWithSameTestNameTest,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class. However, in test suite MixedUpTestCaseWithSameTestNameTest,
|
||||
you defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail
|
||||
using two different test fixture classes. This can happen if
|
||||
the two classes are from different namespaces or translation
|
||||
units and have the same name. You should probably rename one
|
||||
of the classes to put the tests into different test cases.
|
||||
of the classes to put the tests into different test suites.
|
||||
Stack trace: (omitted)
|
||||
|
||||
[0;31m[ FAILED ] [mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail
|
||||
@@ -437,9 +437,9 @@ Stack trace: (omitted)
|
||||
[0;32m[ RUN ] [mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class, so mixing TEST_F and TEST in the same test case is
|
||||
illegal. In test case TEST_F_before_TEST_in_same_test_case,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class, so mixing TEST_F and TEST in the same test suite is
|
||||
illegal. In test suite TEST_F_before_TEST_in_same_test_case,
|
||||
test DefinedUsingTEST_F is defined using TEST_F but
|
||||
test DefinedUsingTESTAndShouldFail is defined using TEST. You probably
|
||||
want to change the TEST to TEST_F or move it to another test
|
||||
@@ -453,9 +453,9 @@ Stack trace: (omitted)
|
||||
[0;32m[ RUN ] [mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class, so mixing TEST_F and TEST in the same test case is
|
||||
illegal. In test case TEST_before_TEST_F_in_same_test_case,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class, so mixing TEST_F and TEST in the same test suite is
|
||||
illegal. In test suite TEST_before_TEST_F_in_same_test_case,
|
||||
test DefinedUsingTEST_FAndShouldFail is defined using TEST_F but
|
||||
test DefinedUsingTEST is defined using TEST. You probably
|
||||
want to change the TEST to TEST_F or move it to another test
|
||||
@@ -912,9 +912,9 @@ DynamicFixture::TearDown
|
||||
DynamicFixture()
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class, so mixing TEST_F and TEST in the same test case is
|
||||
illegal. In test case BadDynamicFixture1,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class, so mixing TEST_F and TEST in the same test suite is
|
||||
illegal. In test suite BadDynamicFixture1,
|
||||
test FixtureBase is defined using TEST_F but
|
||||
test TestBase is defined using TEST. You probably
|
||||
want to change the TEST to TEST_F or move it to another test
|
||||
@@ -936,13 +936,13 @@ DynamicFixture::TearDown
|
||||
DynamicFixture()
|
||||
gtest.cc:#: Failure
|
||||
Failed
|
||||
All tests in the same test case must use the same test fixture
|
||||
class. However, in test case BadDynamicFixture2,
|
||||
All tests in the same test suite must use the same test fixture
|
||||
class. However, in test suite BadDynamicFixture2,
|
||||
you defined test FixtureBase and test Derived
|
||||
using two different test fixture classes. This can happen if
|
||||
the two classes are from different namespaces or translation
|
||||
units and have the same name. You should probably rename one
|
||||
of the classes to put the tests into different test cases.
|
||||
of the classes to put the tests into different test suites.
|
||||
Stack trace: (omitted)
|
||||
|
||||
~DynamicFixture()
|
||||
@@ -984,7 +984,7 @@ Failed
|
||||
Expected fatal failure.
|
||||
Stack trace: (omitted)
|
||||
|
||||
[0;32m[==========] [m83 tests from 38 test cases ran.
|
||||
[0;32m[==========] [m83 tests from 38 test suites ran.
|
||||
[0;32m[ PASSED ] [m30 tests.
|
||||
[0;31m[ FAILED ] [m53 tests, listed below:
|
||||
[0;31m[ FAILED ] [mNonfatalFailureTest.EscapesStringOperands
|
||||
@@ -1045,7 +1045,7 @@ Stack trace: (omitted)
|
||||
[0;33m YOU HAVE 1 DISABLED TEST
|
||||
|
||||
[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*
|
||||
[==========] Running 4 tests from 2 test cases.
|
||||
[==========] Running 4 tests from 2 test suites.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 3 tests from FatalFailureTest
|
||||
[ RUN ] FatalFailureTest.FatalFailureInSubroutine
|
||||
@@ -1098,7 +1098,7 @@ Stack trace: (omitted)
|
||||
[----------] 1 test from LoggingTest (? ms total)
|
||||
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 4 tests from 2 test cases ran. (? ms total)
|
||||
[==========] 4 tests from 2 test suites ran. (? ms total)
|
||||
[ PASSED ] 0 tests.
|
||||
[ FAILED ] 4 tests, listed below:
|
||||
[ FAILED ] FatalFailureTest.FatalFailureInSubroutine
|
||||
@@ -1108,21 +1108,21 @@ Stack trace: (omitted)
|
||||
|
||||
4 FAILED TESTS
|
||||
Note: Google Test filter = *DISABLED_*
|
||||
[==========] Running 1 test from 1 test case.
|
||||
[==========] Running 1 test from 1 test suite.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 1 test from DisabledTestsWarningTest
|
||||
[ RUN ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
|
||||
[ OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 1 test from 1 test case ran.
|
||||
[==========] 1 test from 1 test suite ran.
|
||||
[ PASSED ] 1 test.
|
||||
Note: Google Test filter = PassingTest.*
|
||||
Note: This is test shard 2 of 2.
|
||||
[==========] Running 1 test from 1 test case.
|
||||
[==========] Running 1 test from 1 test suite.
|
||||
[----------] Global test environment set-up.
|
||||
[----------] 1 test from PassingTest
|
||||
[ RUN ] PassingTest.PassingTest2
|
||||
[ OK ] PassingTest.PassingTest2
|
||||
[----------] Global test environment tear-down
|
||||
[==========] 1 test from 1 test case ran.
|
||||
[==========] 1 test from 1 test suite ran.
|
||||
[ PASSED ] 1 test.
|
||||
|
||||
@@ -249,7 +249,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {
|
||||
TEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {
|
||||
EXPECT_DEATH_IF_SUPPORTED(
|
||||
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C, D"),
|
||||
"foo\\.cc.1.?: No test named D can be found in this test case\\.");
|
||||
"foo\\.cc.1.?: No test named D can be found in this test suite\\.");
|
||||
}
|
||||
|
||||
TEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {
|
||||
@@ -264,7 +264,7 @@ TEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {
|
||||
state_.VerifyRegisteredTestNames("foo.cc", 1, "A, B, C");
|
||||
EXPECT_DEATH_IF_SUPPORTED(
|
||||
state_.AddTestName("foo.cc", 2, "FooTest", "D"),
|
||||
"foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_CASE_P"
|
||||
"foo\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_SUITE_P"
|
||||
"\\(FooTest, \\.\\.\\.\\)\\.");
|
||||
}
|
||||
|
||||
|
||||
@@ -5431,6 +5431,67 @@ TEST_F(SetUpTestCaseTest, Test2) {
|
||||
EXPECT_STREQ("123", shared_resource_);
|
||||
}
|
||||
|
||||
// Tests SetupTestSuite/TearDown TestSuite API
|
||||
class SetUpTestSuiteTest : public Test {
|
||||
protected:
|
||||
// This will be called once before the first test in this test case
|
||||
// is run.
|
||||
static void SetUpTestSuite() {
|
||||
printf("Setting up the test suite . . .\n");
|
||||
|
||||
// Initializes some shared resource. In this simple example, we
|
||||
// just create a C string. More complex stuff can be done if
|
||||
// desired.
|
||||
shared_resource_ = "123";
|
||||
|
||||
// Increments the number of test cases that have been set up.
|
||||
counter_++;
|
||||
|
||||
// SetUpTestSuite() should be called only once.
|
||||
EXPECT_EQ(1, counter_);
|
||||
}
|
||||
|
||||
// This will be called once after the last test in this test case is
|
||||
// run.
|
||||
static void TearDownTestSuite() {
|
||||
printf("Tearing down the test suite . . .\n");
|
||||
|
||||
// Decrements the number of test suites that have been set up.
|
||||
counter_--;
|
||||
|
||||
// TearDownTestSuite() should be called only once.
|
||||
EXPECT_EQ(0, counter_);
|
||||
|
||||
// Cleans up the shared resource.
|
||||
shared_resource_ = nullptr;
|
||||
}
|
||||
|
||||
// This will be called before each test in this test case.
|
||||
void SetUp() override {
|
||||
// SetUpTestSuite() should be called only once, so counter_ should
|
||||
// always be 1.
|
||||
EXPECT_EQ(1, counter_);
|
||||
}
|
||||
|
||||
// Number of test suites that have been set up.
|
||||
static int counter_;
|
||||
|
||||
// Some resource to be shared by all tests in this test case.
|
||||
static const char* shared_resource_;
|
||||
};
|
||||
|
||||
int SetUpTestSuiteTest::counter_ = 0;
|
||||
const char* SetUpTestSuiteTest::shared_resource_ = nullptr;
|
||||
|
||||
// A test that uses the shared resource.
|
||||
TEST_F(SetUpTestSuiteTest, TestSetupTestSuite1) {
|
||||
EXPECT_STRNE(nullptr, shared_resource_);
|
||||
}
|
||||
|
||||
// Another test that uses the shared resource.
|
||||
TEST_F(SetUpTestSuiteTest, TestSetupTestSuite2) {
|
||||
EXPECT_STREQ("123", shared_resource_);
|
||||
}
|
||||
|
||||
// The ParseFlagsTest test case tests ParseGoogleTestFlagsOnly.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user