32 """Unit test for the gtest_xml_output module.""" 34 __author__ =
"keith.ray@gmail.com (Keith Ray)" 37 from xml.dom
import minidom, Node
39 import gtest_test_utils
40 import gtest_xml_test_utils
43 GTEST_OUTPUT_SUBDIR =
"xml_outfiles" 44 GTEST_OUTPUT_1_TEST =
"gtest_xml_outfile1_test_" 45 GTEST_OUTPUT_2_TEST =
"gtest_xml_outfile2_test_" 47 EXPECTED_XML_1 =
"""<?xml version="1.0" encoding="UTF-8"?> 48 <testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests"> 49 <testsuite name="PropertyOne" tests="1" failures="0" disabled="0" errors="0" time="*"> 50 <testcase name="TestSomeProperties" status="run" time="*" classname="PropertyOne" SetUpProp="1" TestSomeProperty="1" TearDownProp="1" /> 55 EXPECTED_XML_2 =
"""<?xml version="1.0" encoding="UTF-8"?> 56 <testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests"> 57 <testsuite name="PropertyTwo" tests="1" failures="0" disabled="0" errors="0" time="*"> 58 <testcase name="TestSomeProperties" status="run" time="*" classname="PropertyTwo" SetUpProp="2" TestSomeProperty="2" TearDownProp="2" /> 65 """Unit test for Google Test's XML output functionality.""" 72 GTEST_OUTPUT_SUBDIR,
"")
80 os.remove(os.path.join(self.
output_dir_, GTEST_OUTPUT_1_TEST +
".xml"))
84 os.remove(os.path.join(self.
output_dir_, GTEST_OUTPUT_2_TEST +
".xml"))
100 command = [gtest_prog_path,
"--gtest_output=xml:%s" % self.
output_dir_]
103 self.assertTrue(p.exited)
104 self.assertEqual(0, p.exit_code)
111 output_file_name1 = test_name +
".xml" 112 output_file1 = os.path.join(self.
output_dir_, output_file_name1)
113 output_file_name2 =
'lt-' + output_file_name1
114 output_file2 = os.path.join(self.
output_dir_, output_file_name2)
115 self.assertTrue(os.path.isfile(output_file1)
or os.path.isfile(output_file2),
118 expected = minidom.parseString(expected_xml)
119 if os.path.isfile(output_file1):
120 actual = minidom.parse(output_file1)
122 actual = minidom.parse(output_file2)
125 actual.documentElement)
130 if __name__ ==
"__main__":
131 os.environ[
"GTEST_STACK_TRACE_DEPTH"] =
"0" def GetTestExecutablePath(executable_name, build_dir=None)
def AssertEquivalentNodes(self, expected_node, actual_node)
def DeleteFilesAndDir(self)
def NormalizeXml(self, element)
def _TestOutFile(self, test_name, expected_xml)