diff --git a/test/appium/support/github_report.py b/test/appium/support/github_report.py index 9196c10e06..f14d9ea2ec 100644 --- a/test/appium/support/github_report.py +++ b/test/appium/support/github_report.py @@ -81,19 +81,29 @@ class GithubHtmlReport(BaseTestReport): tr_case_ids=','.join([str(test.testrail_case_id) for test in tests])) if not not_executed_tests: + groups = {i: list() for i in set([test.group_name for test in tests])} + for i in tests: + groups[i.group_name].append(i) + html += "
" - html += "" - html += "" - html += "" - html += "" - html += "" - html += "" - html += "" - html += "" - for i, test in enumerate(tests): - html += self.build_test_row_html(i, test, run_id) - html += "" - html += "
" + + for class_name, tests_list in groups.items(): + if class_name: + html += "

Class %s:

" % class_name + else: + html += "

Single device tests:

" + html += "" + html += "" + html += "" + html += "" + html += "" + html += "" + html += "" + html += "" + for i, test in enumerate(tests_list): + html += self.build_test_row_html(i, test, run_id) + html += "" + html += "
" html += "" return html diff --git a/test/appium/support/testrail_report.py b/test/appium/support/testrail_report.py index 66b673d161..ad78ec7ef3 100644 --- a/test/appium/support/testrail_report.py +++ b/test/appium/support/testrail_report.py @@ -245,17 +245,19 @@ class TestrailReport(BaseTestReport): description_title += "Not executed tests: %d\n" % len(not_executed_tests) description_title += "\n" ids_failed_test = [] - description, case_info = '', '' + single_devices_block, group_blocks, case_info = str(), dict(), str() if failed_tests: - for i, test in enumerate(failed_tests): + for test in failed_tests: + if test.group_name: + group_blocks[test.group_name] = "-------\n## Class: %s:\n" % test.group_name + for test in failed_tests: last_testrun = test.testruns[-1] test_rail_link = self.get_test_result_link(self.run_id, test.testrail_case_id) ids_failed_test.append(test.testrail_case_id) case_title = '\n' case_title += '-------\n' - case_title += "## %s) ID %s: [%s](%s) \n" % ( - i + 1, test.testrail_case_id, test.name, test_rail_link) - full_error = last_testrun.error[:255] + case_title += "## ID %s: [%s](%s) \n" % (test.testrail_case_id, test.name, test_rail_link) + full_error = last_testrun.error[-255:] (code_error, no_code_error_str, issue_id) = self.separate_xfail_error(full_error) if issue_id: test_rail_xfail = self.make_error_with_gh_issue_link(no_code_error_str, issue_id) @@ -272,14 +274,13 @@ class TestrailReport(BaseTestReport): % (f, job_url, self.get_sauce_final_screenshot_url(job_id)) if test.group_name: - class_name = "Class: %s\n" % test.group_name - description += case_title + class_name + error + case_info + group_blocks[test.group_name] += case_title + error + case_info else: - description += case_title + error + case_info - description_title += '## Failed tests: %s \n' % ','.join(map(str, ids_failed_test)) + single_devices_block += case_title + error + case_info + description_title += '## Failed tests: %s \n' % ','.join(map(str, ids_failed_test)) if not_executed_tests: description_title += "## Not executed tests: %s\n" % ','.join([str(i) for i in not_executed_tests]) - final_description = description_title + description + final_description = description_title + single_devices_block + ''.join([i for i in group_blocks.values()]) request_body = {'description': final_description} return self.post('update_run/%s' % self.run_id, request_body) diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index d1e1b055f4..53b5591c3f 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -238,7 +238,8 @@ def pytest_runtest_makereport(item, call): is_group = "xdist_group" in item.keywords._markers or "xdist_group" in item.parent.keywords._markers error_intro, error = 'Test setup failed:', '' final_error = '%s %s' % (error_intro, error) - if hasattr(report, 'wasxfail'): + if hasattr(report, 'wasxfail') and str([mark.args[0] for mark in item.iter_markers(name='testrail_id')][0]) \ + in str(item.config.getoption("run_testrail_ids")): if '[NOTRUN]' in report.wasxfail: test_suite_data.set_current_test(item.name, testrail_case_id=get_testrail_case_id(item)) test_suite_data.current_test.create_new_testrun() @@ -269,7 +270,9 @@ def pytest_runtest_makereport(item, call): error = catch_error() if report.failed: current_test.testruns[-1].error = error - if hasattr(report, 'wasxfail'): + in_run = str([mark.args[0] for mark in item.iter_markers(name='testrail_id')][0]) in str(item.config.getoption( + "run_testrail_ids")) + if hasattr(report, 'wasxfail') and in_run: current_test.testruns[-1].xfail = report.wasxfail if error: current_test.testruns[-1].error = '%s [[%s]]' % (error, report.wasxfail)