Пример #1
0
 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')
Пример #2
0
 def test_testsuite_class_attributes(self):
     oTestsuite = junit.testsuite('Name', 'Time')
     self.assertTrue(oTestsuite)
     self.assertEqual(oTestsuite.name, 'Name')
     self.assertEqual(oTestsuite.time, 'Time')
     self.assertEqual(oTestsuite.testcases, None)
     self.assertEqual(oTestsuite.timestamp, oTestsuite.timestamp)
Пример #3
0
 def test_testsuite_class_add_testcase(self):
     oTestsuite = junit.testsuite('Name', 'Time')
     oTestsuite.add_testcase(junit.testcase('TC_Name0', 'TC_Time0', 'TC_Classname0'))
     oTestsuite.add_testcase(junit.testcase('TC_Name1', 'TC_Time1', 'TC_Classname1'))
     oTestsuite.add_testcase(junit.testcase('TC_Name2', 'TC_Time2', 'TC_Classname2'))
     self.assertEqual(oTestsuite.testcases[0].name, 'TC_Name0')
     self.assertEqual(oTestsuite.testcases[1].name, 'TC_Name1')
     self.assertEqual(oTestsuite.testcases[2].name, 'TC_Name2')
Пример #4
0
    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())
Пример #5
0
    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())