From c6cb7e033591528a5fe2c63157a0d8ce927740dc Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 13 Dec 2018 12:47:22 -0500 Subject: [PATCH] Googletest export Support skipped in XML and JSON output PiperOrigin-RevId: 225386540 --- googletest/src/gtest.cc | 4 +++- .../test/googletest-json-output-unittest.py | 18 +++++++++++++++++- googletest/test/gtest_xml_output_unittest.py | 19 +++++++++++-------- googletest/test/gtest_xml_output_unittest_.cc | 7 +++++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index db90fe65..34641af3 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3761,7 +3761,8 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, } OutputXmlAttribute(stream, kTestcase, "status", - test_info.should_run() ? "run" : "notrun"); + result.Skipped() ? "skipped" : + test_info.should_run() ? "run" : "notrun"); OutputXmlAttribute(stream, kTestcase, "time", FormatTimeInMillisAsSeconds(result.elapsed_time())); OutputXmlAttribute(stream, kTestcase, "classname", test_case_name); @@ -4126,6 +4127,7 @@ void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream, } OutputJsonKey(stream, kTestcase, "status", + result.Skipped() ? "SKIPPED" : test_info.should_run() ? "RUN" : "NOTRUN", kIndent); OutputJsonKey(stream, kTestcase, "time", FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent); diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py index 57dcd5fa..b09b590e 100644 --- a/googletest/test/googletest-json-output-unittest.py +++ b/googletest/test/googletest-json-output-unittest.py @@ -57,7 +57,7 @@ else: STACK_TRACE_TEMPLATE = '' EXPECTED_NON_EMPTY = { - u'tests': 23, + u'tests': 24, u'failures': 4, u'disabled': 2, u'errors': 0, @@ -123,6 +123,22 @@ EXPECTED_NON_EMPTY = { } ] }, + { + u'name': u'SkippedTest', + u'tests': 1, + u'failures': 0, + u'disabled': 0, + u'errors': 0, + u'time': u'*', + u'testsuite': [ + { + u'name': u'Skipped', + u'status': u'SKIPPED', + u'time': u'*', + u'classname': u'SkippedTest' + } + ] + }, { u'name': u'MixedResultTest', u'tests': 3, diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 8669f19e..ab733d1d 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -65,7 +65,7 @@ else: sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG) EXPECTED_NON_EMPTY_XML = """ - + @@ -108,6 +108,9 @@ Invalid characters in brackets []%(stack)s]]> + + + @@ -183,15 +186,15 @@ EXPECTED_SHARDED_TEST_XML = """ - - - - - - + + + + + + - + """ diff --git a/googletest/test/gtest_xml_output_unittest_.cc b/googletest/test/gtest_xml_output_unittest_.cc index 2ee88380..39d9b4ef 100644 --- a/googletest/test/gtest_xml_output_unittest_.cc +++ b/googletest/test/gtest_xml_output_unittest_.cc @@ -67,6 +67,13 @@ TEST_F(DisabledTest, DISABLED_test_not_run) { FAIL() << "Unexpected failure: Disabled test should not be run"; } +class SkippedTest : public Test { +}; + +TEST_F(SkippedTest, Skipped) { + GTEST_SKIP(); +} + TEST(MixedResultTest, Succeeds) { EXPECT_EQ(1, 1); ASSERT_EQ(1, 1);