예제 #1
0
 def test_testcase_class_add_failure(self):
     oTestcase = junit.testcase('Name', 'Time', 'classname')
     oTestcase.add_failure(junit.failure('Type1'))
     oTestcase.add_failure(junit.failure('Type2'))
     oTestcase.add_failure(junit.failure('Type3'))
     self.assertEqual(oTestcase.failures[0].type, 'Type1')
     self.assertEqual(oTestcase.failures[1].type, 'Type2')
     self.assertEqual(oTestcase.failures[2].type, 'Type3')
예제 #2
0
 def test_testcase_class_build_junit(self):
     oTestcase = junit.testcase('Name', 'Time', 'Classname')
     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)
     dExpected = []
     dExpected.append(
         '  <testcase name="Name" time="Time" classname="Classname">')
     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>')
     self.assertEqual(dExpected, oTestcase.build_junit())
예제 #3
0
 def test_failure_class_add_text(self):
     oFailure = junit.failure('type')
     oFailure.add_text('Text1')
     oFailure.add_text('Text2')
     oFailure.add_text('Text3')
     self.assertEqual(oFailure.type, 'type')
     self.assertEqual(oFailure.text[0], 'Text1')
     self.assertEqual(oFailure.text[1], 'Text2')
     self.assertEqual(oFailure.text[2], 'Text3')
예제 #4
0
 def test_failure_class_build_junit(self):
     oFailure = junit.failure('type')
     oFailure.add_text('Text1')
     oFailure.add_text('Text2')
     oFailure.add_text('Text3')
     dExpected = []
     dExpected.append('    <failure type="type">')
     dExpected.append('      Text1')
     dExpected.append('      Text2')
     dExpected.append('      Text3')
     dExpected.append('    </failure>')
     self.assertEqual(dExpected, oFailure.build_junit())
예제 #5
0
 def test_failure_class_attributes(self):
     oFailure = junit.failure('Type1')
     self.assertTrue(oFailure)
     self.assertEqual(oFailure.type, 'Type1')
     self.assertEqual(oFailure.text, None)
예제 #6
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())