feat: add exception SummaryEmpty

This commit is contained in:
debugtalk
2019-12-24 23:06:39 +08:00
parent 9bd5f62705
commit 9c8f8327ea
3 changed files with 11 additions and 0 deletions

View File

@@ -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**

View File

@@ -74,3 +74,8 @@ class ApiNotFound(NotFoundError):
class TestcaseNotFound(NotFoundError):
pass
class SummaryEmpty(MyBaseError):
""" test result summary data is empty
"""

View File

@@ -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__)),