mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:59:44 +08:00
support validate with response time
This commit is contained in:
@@ -332,3 +332,30 @@ class TestRunner(ApiServerUnittest):
|
||||
self.assertTrue(summary["success"])
|
||||
self.assertEqual(len(summary["details"][0]["output"]), 3 * 2 * 2)
|
||||
self.assertEqual(summary["stat"]["testsRun"], 3 * 2 * 2)
|
||||
|
||||
def test_run_validate_elapsed(self):
|
||||
test = {
|
||||
"name": "get token",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/get-token",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"user_agent": "iOS/10.3",
|
||||
"device_sn": "HZfFBh6tU59EdXJ",
|
||||
"os_platform": "ios",
|
||||
"app_version": "2.8.6"
|
||||
},
|
||||
"json": {
|
||||
"sign": "f1219719911caae89ccc301679857ebfda115ca2"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"check": "status_code", "expect": 200},
|
||||
{"check": "elapsed.seconds", "comparator": "lt", "expect": 1},
|
||||
{"check": "elapsed.days", "comparator": "eq", "expect": 0},
|
||||
{"check": "elapsed.microseconds", "comparator": "gt", "expect": 1000},
|
||||
{"check": "elapsed.total_seconds", "comparator": "lt", "expect": 1}
|
||||
]
|
||||
}
|
||||
self.test_runner.run_test(test)
|
||||
|
||||
Reference in New Issue
Block a user