diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 025c94cb..1eb1cdee 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,6 +5,7 @@ **Added** - feat: store parse failed api/testcase/testsuite file path in `logs/xxx.parse_failed.json` +- feat: add exception SummaryEmpty **Fixed** diff --git a/httprunner/exceptions.py b/httprunner/exceptions.py index 403c5ff8..ad05ea53 100644 --- a/httprunner/exceptions.py +++ b/httprunner/exceptions.py @@ -74,3 +74,8 @@ class ApiNotFound(NotFoundError): class TestcaseNotFound(NotFoundError): pass + + +class SummaryEmpty(MyBaseError): + """ test result summary data is empty + """ diff --git a/httprunner/report/html/gen_report.py b/httprunner/report/html/gen_report.py index dc23d5af..43092849 100644 --- a/httprunner/report/html/gen_report.py +++ b/httprunner/report/html/gen_report.py @@ -5,6 +5,7 @@ from datetime import datetime from jinja2 import Template from httprunner import logger +from httprunner.exceptions import SummaryEmpty def gen_html_report(summary, report_template=None, report_dir=None, report_file=None): @@ -17,6 +18,10 @@ def gen_html_report(summary, report_template=None, report_dir=None, report_file= report_file (str): specify html report file path, this has higher priority than specifying report dir. """ + if not summary["time"] or summary["stat"]["testcases"]["total"] == 0: + logger.log_error("test result summary is empty ! {}".format(summary)) + raise SummaryEmpty + if not report_template: report_template = os.path.join( os.path.abspath(os.path.dirname(__file__)),