From 9e239ff51f985b81187df46da07c6bf239167fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Belleng=C3=A9=20Maxime?= Date: Thu, 30 Jun 2022 11:56:51 +0200 Subject: [PATCH 1/2] Add allow_skip parameter to take into account or not skip status as a valid output --- xtesting/core/robotframework.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xtesting/core/robotframework.py b/xtesting/core/robotframework.py index 775ed1ce..24b6bd45 100644 --- a/xtesting/core/robotframework.py +++ b/xtesting/core/robotframework.py @@ -56,6 +56,9 @@ class RobotFramework(testcase.TestCase): def __init__(self, **kwargs): super().__init__(**kwargs) self.xml_file = os.path.join(self.res_dir, 'output.xml') + # skip_factor is used to determine if SKIP status is taken into account as a successful output into + # in result percentage computation. + self.skip_factor = 0 def parse_results(self): """Parse output.xml and get the details in it.""" @@ -64,7 +67,7 @@ def parse_results(self): result.visit(visitor) try: self.result = 100 * ( - result.suite.statistics.passed / + (result.suite.statistics.passed + self.skip_factor * result.suite.statistics.skipped)/ result.suite.statistics.total) except ZeroDivisionError: self.__logger.error("No test has been run") @@ -103,6 +106,7 @@ def run(self, **kwargs): variable = kwargs.get("variable", []) variablefile = kwargs.get("variablefile", []) include = kwargs.get("include", []) + self.skip_factor = int(kwargs.get("allow_skip", False)) except KeyError: self.__logger.exception("Mandatory args were not passed") return self.EX_RUN_ERROR From f6ec19664787ab8e5f716905d458f52ceb8a3483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Belleng=C3=A9=20Maxime?= Date: Thu, 30 Jun 2022 16:50:56 +0200 Subject: [PATCH 2/2] Add unit tests for allow_skip --- .../tests/unit/core/test_robotframework.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/xtesting/tests/unit/core/test_robotframework.py b/xtesting/tests/unit/core/test_robotframework.py index f36625e6..21b557da 100644 --- a/xtesting/tests/unit/core/test_robotframework.py +++ b/xtesting/tests/unit/core/test_robotframework.py @@ -86,25 +86,41 @@ def _test_result(self, config, result): {'description': config['name'], 'tests': []}) def test_null_passed(self): - self._config.update({'statistics.passed': 0, + self._config.update({'statistics.skipped': 0, + 'statistics.passed': 0, 'statistics.total': 20}) self._test_result(self._config, 0) def test_no_test(self): - self._config.update({'statistics.passed': 20, + self._config.update({'statistics.skipped': 0, + 'statistics.passed': 20, 'statistics.total': 0}) self._test_result(self._config, 0) def test_half_success(self): - self._config.update({'statistics.passed': 10, + self._config.update({'statistics.skipped': 0, + 'statistics.passed': 10, 'statistics.total': 20}) self._test_result(self._config, 50) def test_success(self): - self._config.update({'statistics.passed': 20, + self._config.update({'statistics.skipped': 0, + 'statistics.passed': 20, 'statistics.total': 20}) self._test_result(self._config, 100) + def test_skip_excluded(self): + self._config.update({'statistics.skipped': 1, + 'statistics.passed': 4, + 'statistics.total': 5}) + self._test_result(self._config, 80) + + def test_skip_included(self): + self._config.update({'statistics.skipped': 1, + 'statistics.passed': 4, + 'statistics.total': 5}) + self.test.skip_factor = 1 + self._test_result(self._config, 100) class GenerateReportTesting(unittest.TestCase):