bugfix: display default test suite name if not specified

This commit is contained in:
debugtalk
2018-07-24 20:22:26 +08:00
parent 9b38ad949e
commit 7a2920fac2
2 changed files with 153 additions and 151 deletions

View File

@@ -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')

View File

@@ -187,69 +187,91 @@
{% for test_suite_summary in details %}
{% set suite_index = loop.index %}
<h3>{{test_suite_summary.name}}</h3>
<table id="suite_{{suite_index}}" class="details">
<tr>
<th>base_url</th>
<td colspan="2">{{test_suite_summary.base_url}}</td>
<th colspan="2" class="detail">
<a class="button" href="#suite_output_{{suite_index}}">parameters & output</a>
<div id="suite_output_{{suite_index}}" class="overlay">
<div class="popup">
<h2>Parameters and Output</h2>
<a class="close" href="#suite_{{suite_index}}">&times;</a>
<div class="content">
<div style="overflow: auto">
<table>
<tr>
<th>variables</th>
<th>output</th>
</tr>
{% for in_out in test_suite_summary.output %}
<tr>
<td>{{in_out.in}}</td>
<td>{{in_out.out}}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>TOTAL: {{test_suite_summary.stat.testsRun}}</td>
<td>SUCCESS: {{test_suite_summary.stat.successes}}</td>
<td>FAILED: {{test_suite_summary.stat.failures}}</td>
<td>ERROR: {{test_suite_summary.stat.errors}}</td>
<td>SKIPPED: {{test_suite_summary.stat.skipped}}</td>
</tr>
<tr>
<th>Status</th>
<th colspan="2">Name</th>
<th>Response Time</th>
<th>Detail</th>
</tr>
{% for record in test_suite_summary.records %}
{% set record_index = "{}_{}".format(suite_index, loop.index) %}
<tr id="record_{{record_index}}">
<th class="{{record.status}}" style="width:5em;">{{record.status}}</td>
<td colspan="2">{{record.name}}</td>
<td style="text-align:center;width:6em;">{{ record.meta_data.response.response_time_ms }} ms</td>
<td class="detail">
<a class="button" href="#popup_log_{{record_index}}">log</a>
<div id="popup_log_{{record_index}}" class="overlay">
<table id="suite_{{suite_index}}" class="details">
<tr>
<th>base_url</th>
<td colspan="2">{{test_suite_summary.base_url}}</td>
<th colspan="2" class="detail">
<a class="button" href="#suite_output_{{suite_index}}">parameters & output</a>
<div id="suite_output_{{suite_index}}" class="overlay">
<div class="popup">
<h2>Request and Response data</h2>
<a class="close" href="#record_{{record_index}}">&times;</a>
<h2>Parameters and Output</h2>
<a class="close" href="#suite_{{suite_index}}">&times;</a>
<div class="content">
<div style="overflow: auto">
<table>
<tr>
<th>variables</th>
<th>output</th>
</tr>
{% for in_out in test_suite_summary.output %}
<tr>
<td>{{in_out.in}}</td>
<td>{{in_out.out}}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>TOTAL: {{test_suite_summary.stat.testsRun}}</td>
<td>SUCCESS: {{test_suite_summary.stat.successes}}</td>
<td>FAILED: {{test_suite_summary.stat.failures}}</td>
<td>ERROR: {{test_suite_summary.stat.errors}}</td>
<td>SKIPPED: {{test_suite_summary.stat.skipped}}</td>
</tr>
<tr>
<th>Status</th>
<th colspan="2">Name</th>
<th>Response Time</th>
<th>Detail</th>
</tr>
<div class="content">
<h3>Request:</h3>
<div style="overflow: auto">
<table>
{% for key, value in record.meta_data.request.items() %}
{% for record in test_suite_summary.records %}
{% set record_index = "{}_{}".format(suite_index, loop.index) %}
<tr id="record_{{record_index}}">
<th class="{{record.status}}" style="width:5em;">{{record.status}}</td>
<td colspan="2">{{record.name}}</td>
<td style="text-align:center;width:6em;">{{ record.meta_data.response.response_time_ms }} ms</td>
<td class="detail">
<a class="button" href="#popup_log_{{record_index}}">log</a>
<div id="popup_log_{{record_index}}" class="overlay">
<div class="popup">
<h2>Request and Response data</h2>
<a class="close" href="#record_{{record_index}}">&times;</a>
<div class="content">
<h3>Request:</h3>
<div style="overflow: auto">
<table>
{% for key, value in record.meta_data.request.items() %}
<tr>
<th>{{key}}</th>
<td>
{% if key == "headers" %}
{% for header_key, header_value in record.meta_data.request.headers.items() %}
<div>
<strong>{{ header_key }}</strong>: {{ header_value }}
</div>
{% endfor %}
{% else %}
{{value}}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
<h3>Response:</h3>
<div style="overflow: auto">
<table>
{% for key, value in record.meta_data.response.items() %}
<tr>
<th>{{key}}</th>
<td>
@@ -259,6 +281,12 @@
<strong>{{ header_key }}</strong>: {{ header_value }}
</div>
{% endfor %}
{% elif key == "content_type" %}
{% if value == "image" %}
<img src="{{ record.meta_data.response.body }}" />
{% else %}
<pre>{{ record.meta_data.response.body }}</pre>
{% endif %}
{% else %}
{{value}}
{% endif %}
@@ -266,100 +294,72 @@
</tr>
{% endfor %}
</table>
</div>
<h3>Response:</h3>
<div style="overflow: auto">
<table>
{% for key, value in record.meta_data.response.items() %}
<tr>
<th>{{key}}</th>
<td>
{% if key == "headers" %}
{% for header_key, header_value in record.meta_data.request.headers.items() %}
<div>
<strong>{{ header_key }}</strong>: {{ header_value }}
</div>
{% endfor %}
{% elif key == "content_type" %}
{% if value == "image" %}
<img src="{{ record.meta_data.response.body }}" />
{% else %}
<pre>{{ record.meta_data.response.body }}</pre>
{% endif %}
{% else %}
{{value}}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
<h3>Validators:</h3>
<div style="overflow: auto">
<table>
<tr>
<th>check</th>
<th>comparator</th>
<th>expect value</th>
<th>actual value</th>
</tr>
{% for validator in record.meta_data.validators %}
<tr>
{% if validator.check_result == "pass" %}
<td class="passed">
{% elif validator.check_result == "fail" %}
<td class="failed">
{% elif validator.check_result == "unchecked" %}
<td class="unchecked">
{% endif %}
{{validator.check}}
</td>
<td>{{validator.comparator}}</td>
<td>{{validator.expect}}</td>
<td>{{validator.check_value}}</td>
</tr>
{% endfor %}
</table>
</div>
<h3>Statistics:</h3>
<div style="overflow: auto">
<table>
<tr>
<th>content_size(bytes)</th>
<td>{{ record.meta_data.response.content_size }}</td>
</tr>
<tr>
<th>response_time(ms)</th>
<td>{{ record.meta_data.response.response_time_ms }}</td>
</tr>
<tr>
<th>elapsed(ms)</th>
<td>{{ record.meta_data.response.elapsed_ms }}</td>
</tr>
</table>
</div>
</div>
<h3>Validators:</h3>
<div style="overflow: auto">
<table>
<tr>
<th>check</th>
<th>comparator</th>
<th>expect value</th>
<th>actual value</th>
</tr>
{% for validator in record.meta_data.validators %}
<tr>
{% if validator.check_result == "pass" %}
<td class="passed">
{% elif validator.check_result == "fail" %}
<td class="failed">
{% elif validator.check_result == "unchecked" %}
<td class="unchecked">
{% endif %}
{{validator.check}}
</td>
<td>{{validator.comparator}}</td>
<td>{{validator.expect}}</td>
<td>{{validator.check_value}}</td>
</tr>
{% endfor %}
</table>
</div>
<h3>Statistics:</h3>
<div style="overflow: auto">
<table>
<tr>
<th>content_size(bytes)</th>
<td>{{ record.meta_data.response.content_size }}</td>
</tr>
<tr>
<th>response_time(ms)</th>
<td>{{ record.meta_data.response.response_time_ms }}</td>
</tr>
<tr>
<th>elapsed(ms)</th>
<td>{{ record.meta_data.response.elapsed_ms }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
{% if record.attachment %}
<a class="button" href="#popup_attachment_{{record_index}}">traceback</a>
<div id="popup_attachment_{{record_index}}" class="overlay">
<div class="popup">
<h2>Traceback Message</h2>
<a class="close" href="#record_{{record_index}}">&times;</a>
<div class="content"><pre>{{ record.attachment }}</pre></div>
</div>
{% if record.attachment %}
<a class="button" href="#popup_attachment_{{record_index}}">traceback</a>
<div id="popup_attachment_{{record_index}}" class="overlay">
<div class="popup">
<h2>Traceback Message</h2>
<a class="close" href="#record_{{record_index}}">&times;</a>
<div class="content"><pre>{{ record.attachment }}</pre></div>
</div>
{% endif %}
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</body>