diff options
Diffstat (limited to 'googletest/test/gtest_xml_output_unittest_.cc')
-rw-r--r-- | googletest/test/gtest_xml_output_unittest_.cc | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/googletest/test/gtest_xml_output_unittest_.cc b/googletest/test/gtest_xml_output_unittest_.cc index c95fd66..fe196b6 100644 --- a/googletest/test/gtest_xml_output_unittest_.cc +++ b/googletest/test/gtest_xml_output_unittest_.cc @@ -35,18 +35,20 @@ // // This program will be invoked from a Python unit test. Don't run it // directly. +// clang-format off + +#include <string> #include "gtest/gtest.h" using ::testing::InitGoogleTest; +using ::testing::Test; using ::testing::TestEventListeners; using ::testing::TestWithParam; using ::testing::UnitTest; -using ::testing::Test; using ::testing::Values; -class SuccessfulTest : public Test { -}; +class SuccessfulTest : public Test {}; TEST_F(SuccessfulTest, Succeeds) { SUCCEED() << "This is a success."; @@ -74,6 +76,15 @@ TEST_F(SkippedTest, Skipped) { GTEST_SKIP(); } +TEST_F(SkippedTest, SkippedWithMessage) { + GTEST_SKIP() << "It is good practice to tell why you skip a test."; +} + +TEST_F(SkippedTest, SkippedAfterFailure) { + EXPECT_EQ(1, 2); + GTEST_SKIP() << "It is good practice to tell why you skip a test."; +} + TEST(MixedResultTest, Succeeds) { EXPECT_EQ(1, 1); ASSERT_EQ(1, 1); @@ -101,8 +112,12 @@ TEST(InvalidCharactersTest, InvalidCharactersInMessage) { class PropertyRecordingTest : public Test { public: - static void SetUpTestSuite() { RecordProperty("SetUpTestSuite", "yes"); } + static void SetUpTestSuite() { + RecordProperty("SetUpTestSuite (with whitespace)", "yes and yes"); + RecordProperty("SetUpTestSuite", "yes"); + } static void TearDownTestSuite() { + RecordProperty("TearDownTestSuite (with whitespace)", "aye and aye"); RecordProperty("TearDownTestSuite", "aye"); } }; @@ -147,6 +162,22 @@ TEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) { ExternalUtilityThatCallsRecordProperty("key_for_utility_string", "1"); } +// Ensures that SetUpTestSuite and TearDownTestSuite failures are reported in +// the XML output. +class SetupFailTest : public ::testing::Test { + protected: + static void SetUpTestSuite() { ASSERT_EQ(1, 2); } +}; + +TEST_F(SetupFailTest, NoopPassingTest) {} + +class TearDownFailTest : public ::testing::Test { + protected: + static void TearDownTestSuite() { ASSERT_EQ(1, 2); } +}; + +TEST_F(TearDownFailTest, NoopPassingTest) {} + // Verifies that the test parameter value is output in the 'value_param' // XML attribute for value-parameterized tests. class ValueParamTest : public TestWithParam<int> {}; @@ -154,16 +185,13 @@ TEST_P(ValueParamTest, HasValueParamAttribute) {} TEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {} INSTANTIATE_TEST_SUITE_P(Single, ValueParamTest, Values(33, 42)); -#if GTEST_HAS_TYPED_TEST // Verifies that the type parameter name is output in the 'type_param' // XML attribute for typed tests. template <typename T> class TypedTest : public Test {}; typedef testing::Types<int, long> TypedTestTypes; TYPED_TEST_SUITE(TypedTest, TypedTestTypes); TYPED_TEST(TypedTest, HasTypeParamAttribute) {} -#endif -#if GTEST_HAS_TYPED_TEST_P // Verifies that the type parameter name is output in the 'type_param' // XML attribute for type-parameterized tests. template <typename T> @@ -174,7 +202,6 @@ REGISTER_TYPED_TEST_SUITE_P(TypeParameterizedTestSuite, HasTypeParamAttribute); typedef testing::Types<int, long> TypeParameterizedTestSuiteTypes; // NOLINT INSTANTIATE_TYPED_TEST_SUITE_P(Single, TypeParameterizedTestSuite, TypeParameterizedTestSuiteTypes); -#endif int main(int argc, char** argv) { InitGoogleTest(&argc, argv); @@ -186,3 +213,5 @@ int main(int argc, char** argv) { testing::Test::RecordProperty("ad_hoc_property", "42"); return RUN_ALL_TESTS(); } + +// clang-format on |