32"""Unit test for the gtest_xml_output module."""
35from xml.dom
import minidom, Node
36import gtest_test_utils
37import gtest_xml_test_utils
39GTEST_OUTPUT_SUBDIR =
"xml_outfiles"
40GTEST_OUTPUT_1_TEST =
"gtest_xml_outfile1_test_"
41GTEST_OUTPUT_2_TEST =
"gtest_xml_outfile2_test_"
43EXPECTED_XML_1 =
"""<?xml version="1.0" encoding="UTF-8"?>
44<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
45 <testsuite name="PropertyOne" tests=
"1" failures=
"0" skipped=
"0" disabled=
"0" errors=
"0" time=
"*" timestamp=
"*">
46 <testcase name=
"TestSomeProperties" status=
"run" result=
"completed" time=
"*" timestamp=
"*" classname=
"PropertyOne">
48 <property name=
"SetUpProp" value=
"1"/>
49 <property name=
"TestSomeProperty" value=
"1"/>
50 <property name=
"TearDownProp" value=
"1"/>
57EXPECTED_XML_2 = """<?xml version=
"1.0" encoding=
"UTF-8"?>
58<testsuites tests=
"1" failures=
"0" disabled=
"0" errors=
"0" time=
"*" timestamp=
"*" name=
"AllTests">
59 <testsuite name=
"PropertyTwo" tests=
"1" failures=
"0" skipped=
"0" disabled=
"0" errors=
"0" time=
"*" timestamp=
"*">
60 <testcase name=
"TestSomeProperties" status=
"run" result=
"completed" time=
"*" timestamp=
"*" classname=
"PropertyTwo">
62 <property name=
"SetUpProp" value=
"2"/>
63 <property name=
"TestSomeProperty" value=
"2"/>
64 <property name=
"TearDownProp" value=
"2"/>
72class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):
73 """Unit test for Google Test's XML output functionality."""
80 GTEST_OUTPUT_SUBDIR,
"")
88 os.remove(os.path.join(self.
output_dir_, GTEST_OUTPUT_1_TEST +
".xml"))
92 os.remove(os.path.join(self.
output_dir_, GTEST_OUTPUT_2_TEST +
".xml"))
106 def _TestOutFile(self, test_name, expected_xml):
108 command = [gtest_prog_path,
"--gtest_output=xml:%s" % self.
output_dir_]
111 self.assert_(p.exited)
112 self.assertEquals(0, p.exit_code)
114 output_file_name1 = test_name +
".xml"
115 output_file1 = os.path.join(self.
output_dir_, output_file_name1)
116 output_file_name2 =
'lt-' + output_file_name1
117 output_file2 = os.path.join(self.
output_dir_, output_file_name2)
118 self.assert_(os.path.isfile(output_file1)
or os.path.isfile(output_file2),
121 expected = minidom.parseString(expected_xml)
122 if os.path.isfile(output_file1):
123 actual = minidom.parse(output_file1)
125 actual = minidom.parse(output_file2)
128 actual.documentElement)
133if __name__ ==
"__main__":
134 os.environ[
"GTEST_STACK_TRACE_DEPTH"] =
"0"
def GetTestExecutablePath(executable_name, build_dir=None)
def DeleteFilesAndDir(self)
def _TestOutFile(self, test_name, expected_xml)
def AssertEquivalentNodes(self, expected_node, actual_node)
def NormalizeXml(self, element)