mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
html report: show response time for each test
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
Reference in New Issue
Block a user