import os from support.base_test_report import BaseTestReport from support.testrail_report import TestrailReport class GithubHtmlReport(BaseTestReport): TEST_REPORT_DIR = "%s/../report" % os.path.dirname(os.path.abspath(__file__)) def __init__(self): super(GithubHtmlReport, self).__init__() def build_html_report(self, run_id): tests = self.get_all_tests() passed_tests = self.get_passed_tests() failed_tests = self.get_failed_tests() if len(tests) > 0: title_html = "## %.0f%% of end-end tests have passed\n" % (len(passed_tests) / len(tests) * 100) summary_html = "```\n" summary_html += "Total executed tests: %d\n" % len(tests) summary_html += "Failed tests: %d\n" % len(failed_tests) summary_html += "Passed tests: %d\n" % len(passed_tests) summary_html += "```\n" failed_tests_html = str() passed_tests_html = str() if failed_tests: failed_tests_html = self.build_tests_table_html(failed_tests, run_id, failed_tests=True) if passed_tests: passed_tests_html = self.build_tests_table_html(passed_tests, run_id, failed_tests=False) return title_html + summary_html + failed_tests_html + passed_tests_html else: return None def build_tests_table_html(self, tests, run_id, failed_tests=False): tests_type = "Failed tests" if failed_tests else "Passed tests" html = "
" html += "
" # last 2 steps as summary html += "%s" % ''.join(test_steps_html[-2:]) html += "" html += "" html += "
%s
" % last_testrun.error[:255]
html += "" html += "Device %d:" % i html += "