mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 17:59:36 +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
|
self.report_path = None
|
||||||
|
|
||||||
def _record_test(self, test, result_type, attachment=''):
|
def _record_test(self, test, status, attachment=''):
|
||||||
self.records.append({
|
self.records.append({
|
||||||
'name': test.shortDescription(),
|
'name': test.shortDescription(),
|
||||||
'result_type': result_type,
|
'status': status,
|
||||||
'start_at': datetime.fromtimestamp(test.start_at),
|
'response_time': test.meta_data["response_time"],
|
||||||
'duration': time.time() - test.start_at,
|
'attachment': attachment,
|
||||||
'attachment': attachment
|
"meta_data": test.meta_data
|
||||||
})
|
})
|
||||||
|
|
||||||
def startTestRun(self):
|
def startTestRun(self):
|
||||||
@@ -68,7 +68,6 @@ class HtmlTestResult(unittest.TextTestResult):
|
|||||||
|
|
||||||
def startTest(self, test):
|
def startTest(self, test):
|
||||||
""" add start test time """
|
""" add start test time """
|
||||||
test.start_at = time.time()
|
|
||||||
super(HtmlTestResult, self).startTest(test)
|
super(HtmlTestResult, self).startTest(test)
|
||||||
logger.color_print(test.shortDescription(), "yellow")
|
logger.color_print(test.shortDescription(), "yellow")
|
||||||
|
|
||||||
|
|||||||
@@ -87,14 +87,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Duration</th>
|
<th>Response Time</th>
|
||||||
<th>Info</th>
|
<th>Info</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
<tr>
|
<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>{{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>
|
<td class="info"><pre>{{record.attachment}}</pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user