Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allow_skip parameter to take into account or not skip status as a valid output #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion xtesting/core/robotframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions xtesting/tests/unit/core/test_robotframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down