def test_xmlfile_class_add_testsuite(self): oXmlfile = junit.xmlfile('FileName') oXmlfile.add_testsuite(junit.testsuite('TS_NAME0', 'TS_TIME0')) oXmlfile.add_testsuite(junit.testsuite('TS_NAME1', 'TS_TIME1')) oXmlfile.add_testsuite(junit.testsuite('TS_NAME2', 'TS_TIME2')) self.assertEqual(oXmlfile.testsuites[0].name, 'TS_NAME0') self.assertEqual(oXmlfile.testsuites[1].name, 'TS_NAME1') self.assertEqual(oXmlfile.testsuites[2].name, 'TS_NAME2')
def test_xmlfile_class_no_failures_build_junit(self): self.maxDiff = None oXmlfile = junit.xmlfile('FileName') for x in range(0, 2): oTestsuite = junit.testsuite('TS_Name' + str(x), 'TS_Time' + str(x)) for k in range(0, 3): oTestcase = junit.testcase('Name' + str(k), 'Time' + str(k), 'Classname' + str(k)) oTestsuite.add_testcase(oTestcase) oXmlfile.add_testsuite(oTestsuite) sHostname = platform.uname()[1] dExpected = [] dExpected.append('<?xml version="1.0" ?>') dExpected.append('<testsuite errors="0" hostname="' + sHostname + '" failures="0" timestamp="' + oTestsuite.timestamp + '" tests="3" time="TS_Time0" name="TS_Name0">') dExpected.append(' <properties>') dExpected.append(' </properties>') dExpected.append( ' <testcase name="Name0" time="Time0" classname="Classname0">') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name1" time="Time1" classname="Classname1">') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name2" time="Time2" classname="Classname2">') dExpected.append(' </testcase>') dExpected.append(' <system-out>') dExpected.append(' </system-out>') dExpected.append(' <system-err>') dExpected.append(' </system-err>') dExpected.append('</testsuite>') dExpected.append('<testsuite errors="0" hostname="' + sHostname + '" failures="0" timestamp="' + oTestsuite.timestamp + '" tests="3" time="TS_Time1" name="TS_Name1">') dExpected.append(' <properties>') dExpected.append(' </properties>') dExpected.append( ' <testcase name="Name0" time="Time0" classname="Classname0">') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name1" time="Time1" classname="Classname1">') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name2" time="Time2" classname="Classname2">') dExpected.append(' </testcase>') dExpected.append(' <system-out>') dExpected.append(' </system-out>') dExpected.append(' <system-err>') dExpected.append(' </system-err>') dExpected.append('</testsuite>') self.assertEqual(dExpected, oXmlfile.build_junit())
def test_xmlfile_class_build_junit(self): oXmlfile = junit.xmlfile('FileName') for x in range(0, 2): oTestsuite = junit.testsuite('TS_Name' + str(x), 'TS_Time' + str(x)) for k in range(0, 3): oTestcase = junit.testcase('Name' + str(k), 'Time' + str(k), 'Classname' + str(k)) for i in range(0, 3): oFailure = junit.failure('Type' + str(i)) for j in range(0, 3): oFailure.add_text('Text_' + str(i) + '_' + str(j)) oTestcase.add_failure(oFailure) oTestsuite.add_testcase(oTestcase) oXmlfile.add_testsuite(oTestsuite) sHostname = platform.uname()[1] dExpected = [] dExpected.append('<?xml version="1.0" ?>') dExpected.append('<testsuite errors="0" hostname="' + sHostname + '" failures="9" timestamp="' + oTestsuite.timestamp + '" tests="3" time="TS_Time0" name="TS_Name0">') dExpected.append(' <properties>') dExpected.append(' </properties>') dExpected.append( ' <testcase name="Name0" time="Time0" classname="Classname0">') dExpected.append(' <failure type="Type0">') dExpected.append(' Text_0_0') dExpected.append(' Text_0_1') dExpected.append(' Text_0_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type1">') dExpected.append(' Text_1_0') dExpected.append(' Text_1_1') dExpected.append(' Text_1_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type2">') dExpected.append(' Text_2_0') dExpected.append(' Text_2_1') dExpected.append(' Text_2_2') dExpected.append(' </failure>') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name1" time="Time1" classname="Classname1">') dExpected.append(' <failure type="Type0">') dExpected.append(' Text_0_0') dExpected.append(' Text_0_1') dExpected.append(' Text_0_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type1">') dExpected.append(' Text_1_0') dExpected.append(' Text_1_1') dExpected.append(' Text_1_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type2">') dExpected.append(' Text_2_0') dExpected.append(' Text_2_1') dExpected.append(' Text_2_2') dExpected.append(' </failure>') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name2" time="Time2" classname="Classname2">') dExpected.append(' <failure type="Type0">') dExpected.append(' Text_0_0') dExpected.append(' Text_0_1') dExpected.append(' Text_0_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type1">') dExpected.append(' Text_1_0') dExpected.append(' Text_1_1') dExpected.append(' Text_1_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type2">') dExpected.append(' Text_2_0') dExpected.append(' Text_2_1') dExpected.append(' Text_2_2') dExpected.append(' </failure>') dExpected.append(' </testcase>') dExpected.append(' <system-out>') dExpected.append(' </system-out>') dExpected.append(' <system-err>') dExpected.append(' </system-err>') dExpected.append('</testsuite>') dExpected.append('<testsuite errors="0" hostname="' + sHostname + '" failures="9" timestamp="' + oTestsuite.timestamp + '" tests="3" time="TS_Time1" name="TS_Name1">') dExpected.append(' <properties>') dExpected.append(' </properties>') dExpected.append( ' <testcase name="Name0" time="Time0" classname="Classname0">') dExpected.append(' <failure type="Type0">') dExpected.append(' Text_0_0') dExpected.append(' Text_0_1') dExpected.append(' Text_0_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type1">') dExpected.append(' Text_1_0') dExpected.append(' Text_1_1') dExpected.append(' Text_1_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type2">') dExpected.append(' Text_2_0') dExpected.append(' Text_2_1') dExpected.append(' Text_2_2') dExpected.append(' </failure>') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name1" time="Time1" classname="Classname1">') dExpected.append(' <failure type="Type0">') dExpected.append(' Text_0_0') dExpected.append(' Text_0_1') dExpected.append(' Text_0_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type1">') dExpected.append(' Text_1_0') dExpected.append(' Text_1_1') dExpected.append(' Text_1_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type2">') dExpected.append(' Text_2_0') dExpected.append(' Text_2_1') dExpected.append(' Text_2_2') dExpected.append(' </failure>') dExpected.append(' </testcase>') dExpected.append( ' <testcase name="Name2" time="Time2" classname="Classname2">') dExpected.append(' <failure type="Type0">') dExpected.append(' Text_0_0') dExpected.append(' Text_0_1') dExpected.append(' Text_0_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type1">') dExpected.append(' Text_1_0') dExpected.append(' Text_1_1') dExpected.append(' Text_1_2') dExpected.append(' </failure>') dExpected.append(' <failure type="Type2">') dExpected.append(' Text_2_0') dExpected.append(' Text_2_1') dExpected.append(' Text_2_2') dExpected.append(' </failure>') dExpected.append(' </testcase>') dExpected.append(' <system-out>') dExpected.append(' </system-out>') dExpected.append(' <system-err>') dExpected.append(' </system-err>') dExpected.append('</testsuite>') self.assertEqual(dExpected, oXmlfile.build_junit())
def test_xmlfile_class_attributes(self): oXmlfile = junit.xmlfile('FileName') self.assertTrue(oXmlfile) self.assertEqual(oXmlfile.filename, 'FileName') self.assertEqual(oXmlfile.testsuites, None)