コード例 #1
0
    def test_get_test_results_with_duplicate_class_names(self):
        with_duplicates = ParsedUnitTestResultsWithCommit(
            files=1,
            suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
            cases=[
                UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test1', result='success', message='message1', content='content1', time=1),
                UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test1', result='success', message='message2', content='content2', time=2),
    
                # success state has precedence over skipped
                UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test2', result='success', message='message3', content='content3', time=3),
                UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test2', result='skipped', message='message4', content='content4', time=4),
    
                # only when all runs are skipped, test has state skipped
                UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test3', result='skipped', message='message5', content='content5', time=5),
                UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test3', result='skipped', message='message6', content='content6', time=6),
    
                UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test4', result='success', message='message7', content='content7', time=7),
                UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test4', result='failure', message='message8', content='content8', time=8),
    
                UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test5', result='success', message='message9', content='content9', time=9),
                UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test5', result='error', message='message10', content='content10', time=10),
            ],
            commit='commit'
        )

        self.assertEqual(get_test_results(with_duplicates, False), UnitTestResults(
            files=1,
            suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
            cases=10, cases_skipped=3, cases_failures=1, cases_errors=1, cases_time=55,
            case_results=UnitTestCaseResults([
                ((None, 'class1', 'test1'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test1', result='success', message='message1', content='content1', time=1), UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test1', result='success', message='message2', content='content2', time=2)])),
                ((None, 'class1', 'test2'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test2', result='success', message='message3', content='content3', time=3)], skipped=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test2', result='skipped', message='message4', content='content4', time=4)])),
                ((None, 'class1', 'test3'), dict(skipped=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test3', result='skipped', message='message5', content='content5', time=5), UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test3', result='skipped', message='message6', content='content6', time=6)])),
                ((None, 'class1', 'test4'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test4', result='success', message='message7', content='content7', time=7)], failure=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test4', result='failure', message='message8', content='content8', time=8)])),
                ((None, 'class1', 'test5'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test5', result='success', message='message9', content='content9', time=9)], error=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test5', result='error', message='message10', content='content10', time=10)])),
            ]),
            tests=5, tests_skipped=1, tests_failures=1, tests_errors=1,
            commit='commit'
        ))

        self.assertEqual(get_test_results(with_duplicates, True), UnitTestResults(
            files=1,
            suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
            cases=10, cases_skipped=3, cases_failures=1, cases_errors=1, cases_time=55,
            case_results=UnitTestCaseResults([
                (('test1', 'class1', 'test1'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test1', result='success', message='message1', content='content1', time=1)])),
                (('test2', 'class1', 'test1'), dict(success=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test1', result='success', message='message2', content='content2', time=2)])),
                (('test1', 'class1', 'test2'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test2', result='success', message='message3', content='content3', time=3)])),
                (('test2', 'class1', 'test2'), dict(skipped=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test2', result='skipped', message='message4', content='content4', time=4)])),
                (('test1', 'class1', 'test3'), dict(skipped=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test3', result='skipped', message='message5', content='content5', time=5)])),
                (('test2', 'class1', 'test3'), dict(skipped=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test3', result='skipped', message='message6', content='content6', time=6)])),
                (('test1', 'class1', 'test4'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test4', result='success', message='message7', content='content7', time=7)])),
                (('test2', 'class1', 'test4'), dict(failure=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test4', result='failure', message='message8', content='content8', time=8)])),
                (('test1', 'class1', 'test5'), dict(success=[UnitTestCase(result_file='result', test_file='test1', line=123, class_name='class1', test_name='test5', result='success', message='message9', content='content9', time=9)])),
                (('test2', 'class1', 'test5'), dict(error=[UnitTestCase(result_file='result', test_file='test2', line=123, class_name='class1', test_name='test5', result='error', message='message10', content='content10', time=10)])),
            ]),
            tests=10, tests_skipped=3, tests_failures=1, tests_errors=1,
            commit='commit'
        ))
コード例 #2
0
 def test_get_test_results(self):
     self.assertEqual(get_test_results(ParsedUnitTestResultsWithCommit(
         files=1,
         suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
         cases=[
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class1', test_name='test1', result='success', message='message1', content='content1', time=1),
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class1', test_name='test2', result='skipped', message='message2', content='content2', time=2),
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class1', test_name='test3', result='failure', message='message3', content='content3', time=3),
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test1', result='error', message='message4', content='content4', time=4),
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test2', result='skipped', message='message5', content='content5', time=5),
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test3', result='failure', message='message6', content='content6', time=6),
             UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test4', result='failure', message='message7', content='content7', time=7),
         ],
         commit='commit'
     ), False), UnitTestResults(
         files=1,
         suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
         cases=7, cases_skipped=2, cases_failures=3, cases_errors=1, cases_time=28,
         case_results=UnitTestCaseResults([
             ((None, 'class1', 'test1'), dict(success=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class1', test_name='test1', result='success', message='message1', content='content1', time=1)])),
             ((None, 'class1', 'test2'), dict(skipped=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class1', test_name='test2', result='skipped', message='message2', content='content2', time=2)])),
             ((None, 'class1', 'test3'), dict(failure=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class1', test_name='test3', result='failure', message='message3', content='content3', time=3)])),
             ((None, 'class2', 'test1'), dict(error=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test1', result='error', message='message4', content='content4', time=4)])),
             ((None, 'class2', 'test2'), dict(skipped=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test2', result='skipped', message='message5', content='content5', time=5)])),
             ((None, 'class2', 'test3'), dict(failure=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test3', result='failure', message='message6', content='content6', time=6)])),
             ((None, 'class2', 'test4'), dict(failure=[UnitTestCase(result_file='result', test_file='test', line=123, class_name='class2', test_name='test4', result='failure', message='message7', content='content7', time=7)])),
         ]),
         tests=7, tests_skipped=2, tests_failures=3, tests_errors=1,
         commit='commit'
     ))
コード例 #3
0
    def test_multiple_failures_per_test(self):
        multiple_failures_per_test_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="4" failures="2" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="UnitTests" tests="4" failures="2" disable="0" errors="0" time="10.0">
    <testcase name="TestOne" status="run" time="0.5" classname="ClassOne">
      <failure message="Value of: pi&#x0A;  Actual: 3&#x0A;Expected: 3.14" type=""><![CDATA[../../Source/WebKit/chromium/tests/ClassOneTest.cpp:42
Value of: pi
  Actual: 3
Expected: 3.14]]></failure>
    </testcase>
    <testcase name="TestTwo" status="run" time="0.5" classname="ClassTwo">
      <failure message="Value of: e&#x0A;  Actual: 2&#x0A;Expected: 2.71" type=""><![CDATA[../../Source/WebKit/chromium/tests/ClassTwoTest.cpp:30
Value of: e
  Actual: 2
Expected: 2.71]]></failure>
      <failure message="Value of: tau&#x0A;  Actual: 6&#x0A;Expected: 6.28" type=""><![CDATA[../../Source/WebKit/chromium/tests/ClassTwoTest.cpp:55
Value of: tau
  Actual: 6
Expected: 6.28]]></failure>
    </testcase>
  </testsuite>
</testsuites>"""
        expected = ["ClassOne.TestOne", "ClassTwo.TestTwo"]
        self.assertEqual(
            expected,
            UnitTestResults.results_from_string(
                multiple_failures_per_test_xml))
コード例 #4
0
    def test_nofailures(self):
        no_failures_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="RenderTableCellDeathTest" tests="3" failures="0" disabled="0" errors="0" time="0.677">
    <testcase name="CanSetColumn" status="run" time="0.168" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetColumnIndex" status="run" time="0.129" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetRowIndex" status="run" time="0.123" classname="RenderTableCellDeathTest" />
  </testsuite>
</testsuites>"""
        self.assertEqual([], UnitTestResults.results_from_string(no_failures_xml))
コード例 #5
0
    def test_nofailures(self):
        no_failures_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="3" failures="0" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="RenderTableCellDeathTest" tests="3" failures="0" disabled="0" errors="0" time="0.677">
    <testcase name="CanSetColumn" status="run" time="0.168" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetColumnIndex" status="run" time="0.129" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetRowIndex" status="run" time="0.123" classname="RenderTableCellDeathTest" />
  </testsuite>
</testsuites>"""
        self.assertEqual([], UnitTestResults.results_from_string(no_failures_xml))
コード例 #6
0
 def test_get_test_results_with_empty_cases(self):
     self.assertEqual(get_test_results(ParsedUnitTestResultsWithCommit(
         files=0,
         suites=0, suite_tests=0, suite_skipped=0, suite_failures=0, suite_errors=0, suite_time=0,
         cases=[],
         commit='commit'
     ), False), UnitTestResults(
         files=0,
         suites=0, suite_tests=0, suite_skipped=0, suite_failures=0, suite_errors=0, suite_time=0,
         cases=0, cases_skipped=0, cases_failures=0, cases_errors=0, cases_time=0, case_results=UnitTestCaseResults(),
         tests=0, tests_skipped=0, tests_failures=0, tests_errors=0,
         commit='commit'
     ))
コード例 #7
0
    def test_onefailure(self):
        one_failure_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="4" failures="1" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="RenderTableCellDeathTest" tests="4" failures="1" disabled="0" errors="0" time="0.677">
    <testcase name="CanSetColumn" status="run" time="0.168" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetColumnIndex" status="run" time="0.129" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetRowIndex" status="run" time="0.123" classname="RenderTableCellDeathTest" />
    <testcase name="FAILS_DivAutoZoomParamsTest" status="run" time="0.02" classname="WebFrameTest">
      <failure message="Value of: scale&#x0A;  Actual: 4&#x0A;Expected: 1" type=""><![CDATA[../../Source/WebKit/chromium/tests/WebFrameTest.cpp:191
Value of: scale
  Actual: 4
Expected: 1]]></failure>
    </testcase>
  </testsuite>
</testsuites>"""
        expected = ["WebFrameTest.FAILS_DivAutoZoomParamsTest"]
        self.assertEqual(expected, UnitTestResults.results_from_string(one_failure_xml))
コード例 #8
0
    def test_onefailure(self):
        one_failure_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="4" failures="1" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="RenderTableCellDeathTest" tests="4" failures="1" disabled="0" errors="0" time="0.677">
    <testcase name="CanSetColumn" status="run" time="0.168" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetColumnIndex" status="run" time="0.129" classname="RenderTableCellDeathTest" />
    <testcase name="CrashIfSettingUnsetRowIndex" status="run" time="0.123" classname="RenderTableCellDeathTest" />
    <testcase name="FAILS_DivAutoZoomParamsTest" status="run" time="0.02" classname="WebFrameTest">
      <failure message="Value of: scale&#x0A;  Actual: 4&#x0A;Expected: 1" type=""><![CDATA[../../Source/WebKit/chromium/tests/WebFrameTest.cpp:191
Value of: scale
  Actual: 4
Expected: 1]]></failure>
    </testcase>
  </testsuite>
</testsuites>"""
        expected = ["WebFrameTest.FAILS_DivAutoZoomParamsTest"]
        self.assertEqual(expected, UnitTestResults.results_from_string(one_failure_xml))
コード例 #9
0
    def test_get_stats(self):
        self.assertEqual(get_stats(UnitTestResults(
            files=1,

            suites=2,
            suite_tests=20,
            suite_skipped=5,
            suite_failures=6,
            suite_errors=7,
            suite_time=3,

            cases=40,
            cases_skipped=11,
            cases_failures=12,
            cases_errors=13,
            cases_time=4,
            case_results=UnitTestCaseResults(),

            tests=30,
            tests_skipped=8,
            tests_failures=9,
            tests_errors=10,

            commit='commit'
        )), UnitTestRunResults(
            files=1,
            suites=2,
            duration=3,

            tests=30,
            tests_succ=3,
            tests_skip=8,
            tests_fail=9,
            tests_error=10,

            runs=20,
            runs_succ=2,
            runs_skip=5,
            runs_fail=6,
            runs_error=7,

            commit='commit'
        ))
コード例 #10
0
 def test_get_test_results_with_some_nones(self):
     self.assertEqual(get_test_results(ParsedUnitTestResultsWithCommit(
         files=1,
         suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
         cases=[
             UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test1', result='success', message='message1', content='content1', time=1),
             UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test1', result='skipped', message='message2', content='content2', time=None),
             UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test2', result='failure', message='message3', content='content3', time=2),
             UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test2', result='skipped', message='message4', content='content4', time=None),
         ],
         commit='commit'
     ), False), UnitTestResults(
         files=1,
         suites=2, suite_tests=3, suite_skipped=4, suite_failures=5, suite_errors=6, suite_time=7,
         cases=4, cases_skipped=2, cases_failures=1, cases_errors=0, cases_time=3,
         case_results=UnitTestCaseResults([
             ((None, 'class', 'test1'), dict(success=[UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test1', result='success', message='message1', content='content1', time=1)], skipped=[UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test1', result='skipped', message='message2', content='content2', time=None)])),
             ((None, 'class', 'test2'), dict(failure=[UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test2', result='failure', message='message3', content='content3', time=2)], skipped=[UnitTestCase(result_file='result', test_file=None, line=None, class_name='class', test_name='test2', result='skipped', message='message4', content='content4', time=None)])),
         ]),
         tests=2, tests_skipped=0, tests_failures=1, tests_errors=0,
         commit='commit'
     ))
コード例 #11
0
    def test_multiple_failures_per_test(self):
        multiple_failures_per_test_xml = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="4" failures="2" disabled="0" errors="0" time="11.35" name="AllTests">
  <testsuite name="UnitTests" tests="4" failures="2" disable="0" errors="0" time="10.0">
    <testcase name="TestOne" status="run" time="0.5" classname="ClassOne">
      <failure message="Value of: pi&#x0A;  Actual: 3&#x0A;Expected: 3.14" type=""><![CDATA[../../Source/WebKit/chromium/tests/ClassOneTest.cpp:42
Value of: pi
  Actual: 3
Expected: 3.14]]></failure>
    </testcase>
    <testcase name="TestTwo" status="run" time="0.5" classname="ClassTwo">
      <failure message="Value of: e&#x0A;  Actual: 2&#x0A;Expected: 2.71" type=""><![CDATA[../../Source/WebKit/chromium/tests/ClassTwoTest.cpp:30
Value of: e
  Actual: 2
Expected: 2.71]]></failure>
      <failure message="Value of: tau&#x0A;  Actual: 6&#x0A;Expected: 6.28" type=""><![CDATA[../../Source/WebKit/chromium/tests/ClassTwoTest.cpp:55
Value of: tau
  Actual: 6
Expected: 6.28]]></failure>
    </testcase>
  </testsuite>
</testsuites>"""
        expected = ["ClassOne.TestOne", "ClassTwo.TestTwo"]
        self.assertEqual(expected, UnitTestResults.results_from_string(multiple_failures_per_test_xml))
コード例 #12
0
ファイル: unittestresults_unittest.py プロジェクト: EQ4/h5vcc
 def test_nostring(self):
     self.assertEqual(None, UnitTestResults.results_from_string(None))
コード例 #13
0
 def test_emptystring(self):
     self.assertIsNone(UnitTestResults.results_from_string(""))
コード例 #14
0
 def test_nostring(self):
     self.assertIsNone(UnitTestResults.results_from_string(None))
コード例 #15
0
 def test_emptystring(self):
     self.assertIsNone(UnitTestResults.results_from_string(""))
コード例 #16
0
 def test_nostring(self):
     self.assertIsNone(UnitTestResults.results_from_string(None))
コード例 #17
0
ファイル: unittestresults_unittest.py プロジェクト: EQ4/h5vcc
 def test_emptystring(self):
     self.assertEqual(None, UnitTestResults.results_from_string(""))
コード例 #18
0
 def test_emptystring(self):
     self.assertEqual(None, UnitTestResults.results_from_string(""))
コード例 #19
0
 def test_nostring(self):
     self.assertEqual(None, UnitTestResults.results_from_string(None))