From 7a2920fac2ef58059190590296e459db1553380b Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 24 Jul 2018 20:22:26 +0800 Subject: [PATCH] bugfix: display default test suite name if not specified --- httprunner/report.py | 4 +- .../templates/default_report_template.html | 300 +++++++++--------- 2 files changed, 153 insertions(+), 151 deletions(-) diff --git a/httprunner/report.py b/httprunner/report.py index 7cb6b172..73381570 100644 --- a/httprunner/report.py +++ b/httprunner/report.py @@ -90,7 +90,9 @@ def render_html_report(summary, html_report_name=None, html_report_template=None if not os.path.isdir(report_dir_path): os.makedirs(report_dir_path) - for suite_summary in summary["details"]: + for index, suite_summary in enumerate(summary["details"]): + if not suite_summary.get("name"): + suite_summary["name"] = "test suite {}".format(index) for record in suite_summary.get("records"): meta_data = record['meta_data'] stringify_data(meta_data, 'request') diff --git a/httprunner/templates/default_report_template.html b/httprunner/templates/default_report_template.html index 12cc8d94..78d36986 100644 --- a/httprunner/templates/default_report_template.html +++ b/httprunner/templates/default_report_template.html @@ -187,69 +187,91 @@ {% for test_suite_summary in details %} {% set suite_index = loop.index %}

{{test_suite_summary.name}}

- - - - - - - - - - - - - - - - - - - - {% for record in test_suite_summary.records %} - {% set record_index = "{}_{}".format(suite_index, loop.index) %} - - - - + + {% endfor %} +
base_url{{test_suite_summary.base_url}} - parameters & output -
- -
- -
TOTAL: {{test_suite_summary.stat.testsRun}}SUCCESS: {{test_suite_summary.stat.successes}}FAILED: {{test_suite_summary.stat.failures}}ERROR: {{test_suite_summary.stat.errors}}SKIPPED: {{test_suite_summary.stat.skipped}}
StatusNameResponse TimeDetail
{{record.status}} - {{record.name}}{{ record.meta_data.response.response_time_ms }} ms - - log -
{% endfor %} \ No newline at end of file