Skip to content

Commit

Permalink
e2e: mark skipped tests in TR
Browse files Browse the repository at this point in the history
  • Loading branch information
yevh-berdnyk committed Dec 2, 2024
1 parent 1d7eb49 commit e67f6c1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion test/appium/support/base_test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def get_all_tests(self):
jobs=testrun_data['jobs'],
error=testrun_data['error'],
first_commands=testrun_data['first_commands'],
xfail=testrun_data['xfail']))
xfail=testrun_data['xfail'],
run=testrun_data['run']))
tests.append(SingleTestData(name=test_data['name'],
logs_paths=test_data['logs_paths'],
testruns=testruns,
Expand Down
7 changes: 5 additions & 2 deletions test/appium/support/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ def __init__(self, name, testruns, testrail_case_id, logs_paths, grop_name, secu
self.secured = secured

class TestRunData(object):
def __init__(self, steps, jobs, error, first_commands: Dict[str, int], xfail):
def __init__(self, steps, jobs, error, first_commands: Dict[str, int], xfail, run):
self.steps = steps
self.jobs = jobs
self.error = error
self.first_commands = first_commands
self.xfail = xfail
self.run = run

def create_new_testrun(self):
self.testruns.append(SingleTestData.TestRunData(list(), dict(), None, dict(), xfail=''))
self.testruns.append(SingleTestData.TestRunData(
steps=list(), jobs=dict(), error=None, first_commands=dict(), xfail='', run=True
))


class TestSuiteData(object):
Expand Down
12 changes: 10 additions & 2 deletions test/appium/support/testrail_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def __init__(self):

self.outcomes = {
'passed': 1,
'undefined_fail': 10}
'undefined_fail': 10,
'skipped': 11}

self.headers = dict()
self.headers['Authorization'] = 'Basic %s' % str(
Expand Down Expand Up @@ -185,9 +186,16 @@ def add_results(self):
comment += '%s' % ('# Error: \n %s \n' % emoji.demojize(error)) + devices + test_steps
else:
comment += devices + test_steps

if last_testrun.xfail and not last_testrun.run:
status_id = self.outcomes['skipped']
elif last_testrun.error:
status_id = self.outcomes['undefined_fail']
else:
status_id = self.outcomes['passed']
data.append(
{'case_id': test.testrail_case_id,
'status_id': self.outcomes['undefined_fail'] if last_testrun.error else self.outcomes['passed'],
'status_id': status_id,
'comment': comment})

results = self.post('add_results_for_cases/%s' % self.run_id, data={"results": data})
Expand Down
3 changes: 3 additions & 0 deletions test/appium/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def catch_error():
if is_group:
test_suite_data.current_test.group_name = item.instance.__class__.__name__
test_suite_data.current_test.testruns[-1].xfail = report.wasxfail
test_suite_data.current_test.testruns[-1].run = False
error_intro, error = 'Test is not run, e2e blocker ', report.wasxfail
final_error = "%s [[%s]]" % (error_intro, error)
else:
Expand Down Expand Up @@ -381,6 +382,8 @@ def catch_error():
if (hasattr(report, 'wasxfail') and not case_ids_set) or (hasattr(report, 'wasxfail') and (
str([mark.args[0] for mark in item.iter_markers(name='testrail_id')][0]) in str(case_ids_set))):
current_test.testruns[-1].xfail = report.wasxfail
if '[NOTRUN]' in report.wasxfail:
current_test.testruns[-1].run = False
if error:
current_test.testruns[-1].error = '%s [[%s]]' % (error, report.wasxfail)
if is_sauce_env:
Expand Down

0 comments on commit e67f6c1

Please sign in to comment.