html report: show response time for each test

This commit is contained in:
debugtalk
2018-02-26 00:34:55 +08:00
parent 02d41c4e51
commit 89a1a35629
2 changed files with 8 additions and 9 deletions

View File

@@ -54,13 +54,13 @@ class HtmlTestResult(unittest.TextTestResult):
)
self.report_path = None
def _record_test(self, test, result_type, attachment=''):
def _record_test(self, test, status, attachment=''):
self.records.append({
'name': test.shortDescription(),
'result_type': result_type,
'start_at': datetime.fromtimestamp(test.start_at),
'duration': time.time() - test.start_at,
'attachment': attachment
'status': status,
'response_time': test.meta_data["response_time"],
'attachment': attachment,
"meta_data": test.meta_data
})
def startTestRun(self):
@@ -68,7 +68,6 @@ class HtmlTestResult(unittest.TextTestResult):
def startTest(self, test):
""" add start test time """
test.start_at = time.time()
super(HtmlTestResult, self).startTest(test)
logger.color_print(test.shortDescription(), "yellow")

View File

@@ -87,14 +87,14 @@
<tr>
<th>Status</th>
<th>Name</th>
<th>Duration</th>
<th>Response Time</th>
<th>Info</th>
</tr>
{% for record in records %}
<tr>
<th class="{{record.result_type}}" style="width:5em;">{{record.result_type}}</td>
<th class="{{record.status}}" style="width:5em;">{{record.status}}</td>
<td>{{record.name}}</td>
<td style="text-align:right;width:6em;">{{ '%0.3f'| format(record.duration|float) }} seconds</td>
<td style="text-align:center;width:6em;">{{ '%0.1f'| format(record.response_time|float) }} ms</td>
<td class="info"><pre>{{record.attachment}}</pre></td>
</tr>
{% endfor %}