Exemple #1
0
 def test_console_multiple_results_with_retries(self):
     saved_stdout = sys.stdout
     results = ResultList()
     res1 = Result()
     res1.set_verdict("fail", 1001, 1)
     res1.retries_left = 1
     res2 = Result()
     res2.set_verdict("pass", 0, 1)
     res2.retries_left = 0
     results.append(res1)
     results.append(res2)
     results.append(Result())
     results.append(Result())
     results.append(Result())
     try:
         out = StringIO()
         sys.stdout = out
         report = ReportConsole(results)
         report.generate()
         output = out.getvalue().strip()
         lines = output.split("\n")
         self.assertEqual(len(lines), 21)
         self.assertRegexpMatches(lines[3], "Yes", lines[4])
         self.assertRegexpMatches(lines[4], "No", lines[5])
         self.assertRegexpMatches(lines[12], "Final Verdict.*INCONCLUSIVE",
                                  lines[12])
         self.assertRegexpMatches(lines[13], "count.*5", lines[13])
         self.assertRegexpMatches(lines[14], r"passrate.*50.00 \%",
                                  lines[14])
     finally:
         sys.stdout = saved_stdout
Exemple #2
0
 def test_console_pass_with_retries(self):
     saved_stdout = sys.stdout
     results = ResultList()
     res1 = Result()
     res1.set_verdict("fail", 1001, 1)
     res1.retries_left = 1
     res2 = Result()
     res2.set_verdict("pass", 0, 1)
     res2.retries_left = 0
     results.append(res1)
     results.append(res2)
     try:
         out = StringIO()
         sys.stdout = out
         report = ReportConsole(results)
         report.generate()
         output = out.getvalue().strip()
         lines = output.split("\n")
         self.assertEqual(len(lines), 17)
         self.assertRegexpMatches(lines[3], "Yes", lines[4])
         self.assertRegexpMatches(lines[4], "No", lines[5])
         self.assertRegexpMatches(lines[9], "Final Verdict.*PASS", lines[9])
         self.assertRegexpMatches(lines[10], "count.*2", lines[10])
         self.assertRegexpMatches(lines[11], r"passrate.*50.00 \%",
                                  lines[11])
         self.assertRegexpMatches(lines[12],
                                  r"passrate excluding retries.*100.00 \%",
                                  lines[12])
     finally:
         sys.stdout = saved_stdout
Exemple #3
0
    def test_set_verdict(self):
        result = Result()
        result.set_verdict("pass", 0, 10)
        self.assertEqual(result.get_verdict(), "pass")
        self.assertEqual(result.retcode, 0)
        self.assertEqual(result.get_duration(), '0:00:10')
        self.assertEqual(result.get_duration(True), '10')

        with self.assertRaises(ValueError):
            result.set_verdict("wat")
Exemple #4
0
    def create_new_result(verdict, retcode, duration, input_data):
        """
        Create a new Result object with data in function arguments.

        :param verdict: Verdict as string
        :param retcode: Return code as int
        :param duration: Duration as time
        :param input_data: Input data as dictionary
        :return: Result
        """
        new_result = Result(input_data)
        new_result.set_verdict(verdict, retcode, duration)
        return new_result
Exemple #5
0
    def parse_unity_result(self, dut):
        """
        Parses given DUTs stdout for Unity test results.
        :param dut: icetea DUT to inspect the results from
        """
        re_unity_test = re.compile(
            r".*\<\*\*\*UnityTest\*\*\*\>TEST\((?P<suite>.*?), (?P<test>.*?)\)\<\/\*\*\*UnityTest\*\*\*\>")  # noqa: E501 # pylint: disable=line-too-long
        re_unity_result = re.compile(
            r".*\<\*\*\*UnityResult\*\*\*\>(?P<result>.*?)\<\/\*\*\*UnityResult\*\*\*\>")  # noqa: E501 # pylint: disable=line-too-long

        test_output = ""
        test_active = False
        test_results = ResultList()
        for line in dut.traces:
            line = line.strip()

            # Activate test output logging
            match = re_unity_test.match(line)
            if match:
                test_active = True
                test_output = ""
                unity_name = match.group("test")
                unity_suite = match.group("suite")
                self.logger.info("parsing %s.%s", unity_suite, unity_name)

            # Log test output
            if test_active:
                test_output += line + "\n"

            # Check if test is over
            match = re_unity_result.match(line)
            if match and test_active:
                unity_result = match.group("result")

                # Create icetea Result()
                test_result = Result(
                    {
                        "testcase": unity_suite + "." + unity_name,
                        "stdout": test_output,
                        "reason": line if unity_result == "FAIL" else ""
                    })
                test_result.build_result_metadata({"toolchain": unity_name})
                # Would need to do runtime analysis to get duration
                test_result.set_verdict(unity_result, 0, 0.0)
                test_results.append(test_result)
                test_active = False
                self.logger.info("finished %s", unity_name)
        return test_results
Exemple #6
0
 def test_get_verdict(self):
     dictionary = {"retcode": 0}
     res = Result(kwargs=dictionary)
     reslist = ResultList()
     reslist.append(res)
     self.assertEquals(reslist.get_verdict(), "pass")
     dictionary = {"retcode": 1}
     res2 = Result(kwargs=dictionary)
     res2.set_verdict(verdict="fail", retcode=1, duration=10)
     reslist.append(res2)
     self.assertEquals(reslist.get_verdict(), "fail")
     res3 = Result()
     res3.set_verdict("inconclusive", 4, 1)
     reslist = ResultList()
     reslist.append(res3)
     self.assertEquals(reslist.get_verdict(), "inconclusive")
     reslist.append(res2)
     self.assertEquals(reslist.get_verdict(), "fail")
Exemple #7
0
 def test_result_metainfo_generation(self):
     pass_result = Result()
     pass_result.set_verdict('pass', 0, 10)
     dinfo = DutInformation("Test_platform", "123456", "1")
     dinfo.build = Build(ref="test_file", type="file")
     pass_result.add_dutinformation(dinfo)
     self.args_tc.branch = "test_branch"
     self.args_tc.commitId = "123456"
     self.args_tc.gitUrl = "url"
     self.args_tc.buildUrl = "url2"
     self.args_tc.campaign = "campaign"
     self.args_tc.jobId = "test_job"
     self.args_tc.toolchain = "toolchain"
     self.args_tc.buildDate = "today"
     pass_result.build_result_metadata(args=self.args_tc)
     self.assertEqual(pass_result.build_branch, "test_branch")
     self.assertEqual(pass_result.buildcommit, "123456")
     self.assertEqual(pass_result.build_git_url, "url")
     self.assertEqual(pass_result.build_url, "url2")
     self.assertEqual(pass_result.campaign, "campaign")
     self.assertEqual(pass_result.job_id, "test_job")
     self.assertEqual(pass_result.toolchain, "toolchain")
     self.assertEqual(pass_result.build_date, "today")
Exemple #8
0
 def test_get_summary(self):
     expected = {
         "count": 3,
         "pass": 1,
         "fail": 1,
         "skip": 0,
         "inconclusive": 1,
         "retries": 1,
         "duration": 10
     }
     dictionary = {"retcode": 0}
     res = Result(kwargs=dictionary)
     dictionary = {"retcode": 1}
     res2 = Result(kwargs=dictionary)
     res2.set_verdict(verdict="fail", retcode=1, duration=5)
     res3 = Result()
     res3.set_verdict("inconclusive", 4, 5)
     res3.retries_left = 1
     resultlist = ResultList()
     resultlist.append(res)
     resultlist.append(res2)
     resultlist.append(res3)
     self.assertDictEqual(resultlist.get_summary(), expected)
Exemple #9
0
    def test_reportconsole_decodefail(self):
        saved_stdout = sys.stdout
        failing_message = "\x00\x00\x00\x00\x00\x00\x01\xc8"
        results = ResultList()
        res = Result()
        res.set_verdict("fail", 1001, 0)
        res.fail_reason = failing_message
        results.append(res)
        try:
            out = StringIO()
            sys.stdout = out
            report = ReportConsole(results)
            report.generate()
            output = out.getvalue().strip()
            lines = output.split("\n")

            self.assertEqual(len(lines), 15)
            self.assertRegexpMatches(lines[8], r"Final Verdict.*FAIL",
                                     lines[8])
            self.assertRegexpMatches(lines[9], r"count.*1", lines[9])
            self.assertRegexpMatches(lines[10], r"passrate.*0.00 \%",
                                     lines[10])
        finally:
            sys.stdout = saved_stdout
Exemple #10
0
 def test_reportconsole_skip(self):
     saved_stdout = sys.stdout
     results = ResultList()
     res = Result()
     res.skip_reason = "Skip_reason"
     res.set_verdict("skip", -1, -1)
     results.append(res)
     try:
         out = StringIO()
         sys.stdout = out
         report = ReportConsole(results)
         report.generate()
         output = out.getvalue().strip()
         lines = output.split("\n")
         self.assertEqual(len(lines), 15)
         self.assertRegexpMatches(lines[3], r"skip.*Skip_reason")
         self.assertRegexpMatches(lines[8], r"Final Verdict.*PASS",
                                  lines[8])
         self.assertRegexpMatches(lines[9], r"count.*1", lines[9])
         self.assertRegexpMatches(lines[11], r"passrate.*0.00 \%",
                                  lines[10])
         self.assertRegexpMatches(lines[12], r"skip.*1", lines[10])
     finally:
         sys.stdout = saved_stdout
Exemple #11
0
 def test_pass_rate(self):
     dictionary = {"retcode": 0}
     res = Result(kwargs=dictionary)
     res.set_verdict(verdict="pass", retcode=0, duration=0)
     dictionary = {"retcode": 1}
     res2 = Result(kwargs=dictionary)
     res2.set_verdict(verdict="fail", retcode=1, duration=5)
     res3 = Result()
     res3.set_verdict("inconclusive", 4, 5)
     res4 = Result(kwargs=dictionary)
     res4.set_verdict(verdict="skip", retcode=1, duration=5)
     resultlist = ResultList()
     resultlist.append(res)
     resultlist.append(res2)
     resultlist.append(res3)
     self.assertEquals(resultlist.pass_rate(), "50.00 %")
     self.assertEquals(resultlist.pass_rate(include_inconclusive=True),
                       "33.33 %")
     self.assertEquals(resultlist.pass_rate(include_skips=True), "50.00 %")
     resultlist.append(res4)
     self.assertEquals(
         resultlist.pass_rate(include_skips=True,
                              include_inconclusive=True), "25.00 %")
Exemple #12
0
 def test_retries_count(self):
     dictionary = {"retcode": 0}
     res = Result(kwargs=dictionary)
     dictionary = {"retcode": 1}
     res2 = Result(kwargs=dictionary)
     res2.set_verdict(verdict="fail", retcode=1, duration=5)
     res3 = Result()
     res3.set_verdict("inconclusive", 4, 5)
     res3.retries_left = 1
     resultlist = ResultList()
     resultlist.append(res)
     resultlist.append(res2)
     resultlist.append(res3)
     self.assertEqual(resultlist.retry_count(), 1)
     res4 = Result()
     res4.set_verdict("inconclusive", 4, 5)
     resultlist.append(res4)
     self.assertEqual(resultlist.retry_count(), 1)
class DummyContainer(TestcaseContainer):
    """
    Class DummyContainer

    subclasses TestcaseContainer, acts as a dummy object for listing test cases
    that were not found when importing test cases.

    """
    def __init__(self, logger=None):
        """
        Just initialize the super class.

        :param logger: logger to use.
        """
        super(DummyContainer, self).__init__(logger)

    @staticmethod
    def find_testcases(modulename,
                       moduleroot,
                       tc_meta_schema,
                       path=None,
                       suiteconfig=None,
                       logger=None):
        """
        Static method find_testcases. Returns a DummyContainer with attributes collected from
        function params.
        """
        dc = DummyContainer(logger)
        dc.tcname = modulename
        dc._modulename = modulename
        dc.status = TestStatus.PENDING
        dc._instance = None
        dc._final_configuration = {}
        dc._moduleroot = moduleroot
        dc._meta_schema = tc_meta_schema
        dc._result = None
        dc._filepath = path
        dc._suiteconfig = suiteconfig if suiteconfig else {}
        return dc

    def run(self, forceflash=False):
        """
        Just returns the Result object for this Dummy.
        """
        return self._result

    def get(self, field):
        return None

    def set_final_config(self):
        pass

    def set_result_verdict(self, reason):
        """
        Sets the inconclusive verdict for this DummyContainer with reason reason.

        :param reason: String reason for why this dummy exists.
        :return: Nothing
        """
        if not self._result:
            self._result = Result()

        self._result.set_verdict(verdict="inconclusive",
                                 retcode=ReturnCodes.RETCODE_FAIL_INCONCLUSIVE,
                                 duration=0)
        self._result.tc_metadata["name"] = self.tcname
        self._result.fail_reason = reason

    def validate_tc_instance(self):
        return True
Exemple #14
0
    def test_run(self, mock_tclist):  # pylint: disable=too-many-statements
        testsuite = TestSuite(args=self.args_tc)
        cont1 = mock.MagicMock()
        pass_result = Result()
        pass_result.set_verdict('pass', 0, 10)
        fail_result = Result()
        fail_result.set_verdict('fail', 1000, 10)
        skipped_result = Result()
        skipped_result.set_verdict('skip', 0, 1)
        resultlist = ResultList()
        resultlist.append(pass_result)
        resultlist.save = mock.MagicMock()
        testsuite._default_configs["retryCount"] = 1
        cont1.run.side_effect = [pass_result,
                                 fail_result,
                                 skipped_result,
                                 KeyboardInterrupt,
                                 fail_result,
                                 pass_result]
        cont_reslist = mock.MagicMock()
        cont_reslist.run = mock.MagicMock()
        cont_reslist.run.return_value = resultlist
        # Passing result
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "pass")
        self.assertTrue(self.args_tc.forceflash)  # pylint: disable=no-member
        self.assertEquals(testsuite._results.save.call_count, 1)

        # ResultList as result
        testsuite._testcases = []
        testsuite._testcases.append(cont_reslist)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "pass")

        # Failing result, no retry
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "fail")

        # skipped result
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "skip")

        # Interrupt
        cont2 = mock.MagicMock()
        cont2.run = mock.MagicMock()
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._testcases.append(cont2)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 0)
        cont2.run.assert_not_called()

        # Failing result, retried
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite._default_configs["retryReason"] = "includeFailures"
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "fail")
        self.assertEqual(testsuite._results.get(1).get_verdict(), "pass")

        # TC not exist result, retried
        testsuite._testcases = []
        contx = mock.MagicMock()
        inconc_res = Result()
        inconc_res.set_verdict("inconclusive", 1015, 0)
        contx.run = mock.MagicMock(return_value=inconc_res)
        testsuite._testcases.append(contx)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite._default_configs["retryReason"] = "includeFailures"
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "inconclusive")

        # Failing result, retried, from a result list.
        testsuite._testcases = []
        fail_result_2 = Result()
        fail_result_2.set_verdict('fail', 1000, 10)
        reslist = ResultList()
        reslist.append(fail_result_2)
        cont_retry = mock.MagicMock()
        cont_retry.run.side_effect = [reslist, resultlist]
        testsuite._testcases.append(cont_retry)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite._default_configs["retryReason"] = "includeFailures"
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "fail")
        self.assertEqual(testsuite._results.get(1).get_verdict(), "pass")
        self.assertEqual(testsuite._results.get(0).retries_left, 1)
        self.assertEqual(testsuite._results.get(1).retries_left, 0)

        # Inconclusive result, retried, from a result list.
        testsuite._testcases = []
        fail_result_3 = Result()
        fail_result_3.set_verdict('inconclusive', 1000, 10)
        reslist = ResultList()
        reslist.append(fail_result_3)
        cont_retry = mock.MagicMock()
        cont_retry.run.side_effect = [reslist, resultlist]
        testsuite._testcases.append(cont_retry)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        testsuite._default_configs["retryReason"] = "includeFailures"
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "inconclusive")
        self.assertEqual(testsuite._results.get(1).get_verdict(), "pass")
        self.assertEqual(testsuite._results.get(0).retries_left, 1)
        self.assertEqual(testsuite._results.get(1).retries_left, 0)

        self.args_tc.repeat = 2
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        cont1.run.side_effect = [pass_result, pass_result, pass_result, pass_result]
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "pass")
        self.assertFalse(self.args_tc.forceflash)  # pylint: disable=no-member

        # Failing result, stop_on_failure
        self.args_tc.stop_on_failure = True
        self.args_tc.repeat = 1
        testsuite._default_configs["retryCount"] = 0
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        cont1.run.side_effect = [pass_result]
        cont2 = mock.MagicMock()
        cont2.run = mock.MagicMock()
        cont2.run.side_effect = [fail_result]
        cont3 = mock.MagicMock()
        cont3.run = mock.MagicMock()
        cont3.run.side_effect = [pass_result]
        testsuite._testcases.append(cont2)
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "pass")
        self.assertEqual(testsuite._results.get(1).get_verdict(), "fail")
        self.assertEquals(testsuite._results.save.call_count, 2)

        # Skipped result, stop_on_failure
        self.args_tc.stop_on_failure = True
        self.args_tc.repeat = 0
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = ResultList()
        testsuite._results.save = mock.MagicMock()
        cont1.run.side_effect = [skipped_result]
        cont2 = mock.MagicMock()
        cont2.run = mock.MagicMock()
        cont2.run.side_effect = [pass_result]
        testsuite._testcases.append(cont2)
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results.get(0).get_verdict(), "skip")
        self.assertEqual(testsuite._results.get(1).get_verdict(), "pass")
        self.assertEquals(testsuite._results.save.call_count, 2)
Exemple #15
0
    def test_run(self, mock_tclist):
        testsuite = TestSuite(args=self.args_tc)
        cont1 = mock.MagicMock()
        pass_result = Result()
        pass_result.set_verdict('pass', 0, 10)
        fail_result = Result()
        fail_result.set_verdict('fail', 1000, 10)
        skipped_result = Result()
        skipped_result.set_verdict('skip', 0, 1)
        resultlist = ResultList()
        resultlist.append(pass_result)
        testsuite._default_configs["retryCount"] = 1
        cont1.run.side_effect = [
            pass_result, fail_result, skipped_result, KeyboardInterrupt,
            fail_result, pass_result
        ]
        cont_reslist = mock.MagicMock()
        cont_reslist.run = mock.MagicMock()
        cont_reslist.run.return_value = resultlist
        # Passing result
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results[0].get_verdict(), "pass")
        self.assertTrue(self.args_tc.forceflash)

        # ResultList as result
        testsuite._testcases = []
        testsuite._testcases.append(cont_reslist)
        testsuite._results = []
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results[0].get_verdict(), "pass")

        # Failing result, no retry
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results[0].get_verdict(), "fail")

        # skipped result
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 1)
        self.assertEqual(testsuite._results[0].get_verdict(), "skip")

        # Interrupt
        cont2 = mock.MagicMock()
        cont2.run = mock.MagicMock()
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._testcases.append(cont2)
        testsuite._results = []
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 0)
        cont2.run.assert_not_called()

        # Failing result, retried
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        testsuite._default_configs["retryReason"] = "includeFailures"
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results[0].get_verdict(), "fail")
        self.assertEqual(testsuite._results[1].get_verdict(), "pass")

        self.args_tc.repeat = 2
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        cont1.run.side_effect = [
            pass_result, pass_result, pass_result, pass_result
        ]
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results[0].get_verdict(), "pass")
        self.assertFalse(self.args_tc.forceflash)

        # Failing result, stop_on_failure
        self.args_tc.stop_on_failure = True
        self.args_tc.repeat = 1
        testsuite._default_configs["retryCount"] = 0
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        cont1.run.side_effect = [pass_result]
        cont2 = mock.MagicMock()
        cont2.run = mock.MagicMock()
        cont2.run.side_effect = [fail_result]
        cont3 = mock.MagicMock()
        cont3.run = mock.MagicMock()
        cont3.run.side_effect = [pass_result]
        testsuite._testcases.append(cont2)
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results[0].get_verdict(), "pass")
        self.assertEqual(testsuite._results[1].get_verdict(), "fail")

        # Skipped result, stop_on_failure
        self.args_tc.stop_on_failure = True
        self.args_tc.repeat = 0
        testsuite._testcases = []
        testsuite._testcases.append(cont1)
        testsuite._results = []
        cont1.run.side_effect = [skipped_result]
        cont2 = mock.MagicMock()
        cont2.run = mock.MagicMock()
        cont2.run.side_effect = [pass_result]
        testsuite._testcases.append(cont2)
        testsuite.run()
        self.assertEqual(testsuite.status, TestStatus.FINISHED)
        self.assertEqual(len(testsuite._results), 2)
        self.assertEqual(testsuite._results[0].get_verdict(), "skip")
        self.assertEqual(testsuite._results[1].get_verdict(), "pass")
Exemple #16
0
    def test_clean_inconcs(self):
        dictionary = {"retcode": 0}
        res = Result(kwargs=dictionary)
        res.set_verdict(verdict="pass", retcode=0, duration=0)
        dictionary = {"retcode": 1}
        res2 = Result(kwargs=dictionary)
        res2.set_verdict(verdict="fail", retcode=1, duration=5)
        res3 = Result()
        res3.set_verdict("inconclusive", 4, 5)
        resultlist = ResultList()
        resultlist.append(res)
        resultlist.append(res2)
        resultlist.append(res3)
        self.assertTrue(resultlist.clean_inconcs())

        dictionary = {"retcode": 0}
        res = Result(kwargs=dictionary)
        res.set_verdict(verdict="pass", retcode=0, duration=0)
        dictionary = {"retcode": 1}
        res2 = Result(kwargs=dictionary)
        res2.set_verdict(verdict="fail", retcode=1, duration=5)
        res2.retries_left = 1
        res3 = Result()
        res3.set_verdict("inconclusive", 4, 5)
        res3.retries_left = 1
        resultlist = ResultList()
        resultlist.append(res)
        resultlist.append(res2)
        resultlist.append(res3)
        res4 = Result()
        res4.set_verdict("inconclusive", 4, 5)
        resultlist.append(res4)
        self.assertTrue(resultlist.clean_inconcs())

        dictionary = {"retcode": 0}
        res = Result(kwargs=dictionary)
        res.set_verdict(verdict="pass", retcode=0, duration=0)
        dictionary = {"retcode": 1}
        res2 = Result(kwargs=dictionary)
        res2.set_verdict(verdict="inconclusive", retcode=1, duration=5)
        res2.retries_left = 1
        res3 = Result()
        res3.set_verdict("pass", 4, 5)
        res3.retries_left = 0
        resultlist = ResultList()
        resultlist.append(res)
        resultlist.append(res2)
        resultlist.append(res3)
        self.assertFalse(resultlist.clean_inconcs())