mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
@@ -39,7 +39,7 @@ To ensure the installation or upgrade is successful, you can execute command `at
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
$ ate -V
|
$ ate -V
|
||||||
ApiTestEngine version: 0.7.0
|
ApiTestEngine version: 0.7.4
|
||||||
```
|
```
|
||||||
|
|
||||||
Execute the command `ate -h` to view command help.
|
Execute the command `ate -h` to view command help.
|
||||||
@@ -75,7 +75,7 @@ To install mail helper, run this command in your terminal:
|
|||||||
$ pip install -U git+https://github.com/debugtalk/jenkins-mail-py.git#egg=jenkins-mail-py
|
$ pip install -U git+https://github.com/debugtalk/jenkins-mail-py.git#egg=jenkins-mail-py
|
||||||
$ ate -V
|
$ ate -V
|
||||||
jenkins-mail-py version: 0.2.5
|
jenkins-mail-py version: 0.2.5
|
||||||
ApiTestEngine version: 0.7.0
|
ApiTestEngine version: 0.7.4
|
||||||
```
|
```
|
||||||
|
|
||||||
With [`jenkins-mail-py`][jenkins-mail-py] installed, you can see more optional arguments.
|
With [`jenkins-mail-py`][jenkins-mail-py] installed, you can see more optional arguments.
|
||||||
@@ -283,7 +283,8 @@ $ python main-locust -h
|
|||||||
- [《ApiTestEngine 演进之路(2)探索优雅的测试用例描述方式》](http://debugtalk.com/post/ApiTestEngine-2-best-testcase-description/)
|
- [《ApiTestEngine 演进之路(2)探索优雅的测试用例描述方式》](http://debugtalk.com/post/ApiTestEngine-2-best-testcase-description/)
|
||||||
- [《ApiTestEngine 演进之路(3)测试用例中实现 Python 函数的定义》](http://debugtalk.com/post/ApiTestEngine-3-define-functions-in-yaml-testcases/)
|
- [《ApiTestEngine 演进之路(3)测试用例中实现 Python 函数的定义》](http://debugtalk.com/post/ApiTestEngine-3-define-functions-in-yaml-testcases/)
|
||||||
- [《ApiTestEngine 演进之路(4)测试用例中实现 Python 函数的调用》](http://debugtalk.com/post/ApiTestEngine-4-call-functions-in-yaml-testcases/)
|
- [《ApiTestEngine 演进之路(4)测试用例中实现 Python 函数的调用》](http://debugtalk.com/post/ApiTestEngine-4-call-functions-in-yaml-testcases/)
|
||||||
|
- [《ApiTestEngine 集成 Locust 实现更好的性能测试体验》](http://debugtalk.com/post/apitestengine-supersede-locust/)
|
||||||
|
- [《约定大于配置:ApiTestEngine实现热加载机制》](http://debugtalk.com/post/apitestengine-hot-plugin/)
|
||||||
|
|
||||||
[requests]: http://docs.python-requests.org/en/master/
|
[requests]: http://docs.python-requests.org/en/master/
|
||||||
[unittest]: https://docs.python.org/3/library/unittest.html
|
[unittest]: https://docs.python.org/3/library/unittest.html
|
||||||
|
|||||||
+1
-2
@@ -197,10 +197,9 @@ class Runner(object):
|
|||||||
try:
|
try:
|
||||||
result = self._run_testset(testset, mapping)
|
result = self._run_testset(testset, mapping)
|
||||||
assert result["success"]
|
assert result["success"]
|
||||||
|
output.update(result["output"])
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
success = False
|
success = False
|
||||||
finally:
|
|
||||||
output.update(result["output"])
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"success": success,
|
"success": success,
|
||||||
|
|||||||
+13
-3
@@ -12,6 +12,7 @@ test_def_overall_dict = {
|
|||||||
"api": {},
|
"api": {},
|
||||||
"suite": {}
|
"suite": {}
|
||||||
}
|
}
|
||||||
|
testcases_cache_mapping = {}
|
||||||
|
|
||||||
|
|
||||||
def extract_variables(content):
|
def extract_variables(content):
|
||||||
@@ -149,16 +150,25 @@ def load_testcases_by_path(path):
|
|||||||
if not os.path.isabs(path):
|
if not os.path.isabs(path):
|
||||||
path = os.path.join(os.getcwd(), path)
|
path = os.path.join(os.getcwd(), path)
|
||||||
|
|
||||||
|
if path in testcases_cache_mapping:
|
||||||
|
return testcases_cache_mapping[path]
|
||||||
|
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
files_list = utils.load_folder_files(path)
|
files_list = utils.load_folder_files(path)
|
||||||
return load_testcases_by_path(files_list)
|
testcases_list = load_testcases_by_path(files_list)
|
||||||
|
|
||||||
elif os.path.isfile(path):
|
elif os.path.isfile(path):
|
||||||
testset = load_test_file(path)
|
testset = load_test_file(path)
|
||||||
if testset["testcases"] or testset["api"]:
|
if testset["testcases"] or testset["api"]:
|
||||||
return [testset]
|
testcases_list = [testset]
|
||||||
|
else:
|
||||||
|
testcases_list = []
|
||||||
|
|
||||||
return []
|
else:
|
||||||
|
testcases_list = []
|
||||||
|
|
||||||
|
testcases_cache_mapping[path] = testcases_list
|
||||||
|
return testcases_list
|
||||||
|
|
||||||
def load_test_file(file_path):
|
def load_test_file(file_path):
|
||||||
""" load testset file, get testset data structure.
|
""" load testset file, get testset data structure.
|
||||||
|
|||||||
@@ -24,3 +24,46 @@
|
|||||||
json:
|
json:
|
||||||
name: $user_name
|
name: $user_name
|
||||||
password: $user_password
|
password: $user_password
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: get_user($uid, $token)
|
||||||
|
request:
|
||||||
|
url: /api/users/$uid
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: update_user($uid, $user_name, $user_password, $token)
|
||||||
|
request:
|
||||||
|
url: /api/users/$uid
|
||||||
|
method: PUT
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
json:
|
||||||
|
name: $user_name
|
||||||
|
password: $user_password
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: delete_user($uid, $token)
|
||||||
|
request:
|
||||||
|
url: /api/users/$uid
|
||||||
|
method: DELETE
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: get_users($token)
|
||||||
|
request:
|
||||||
|
url: /api/users
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|
||||||
|
- api:
|
||||||
|
def: reset_all($token)
|
||||||
|
request:
|
||||||
|
url: /api/reset-all
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
token: $token
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,4 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
|
||||||
import json
|
import json
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
@@ -184,6 +183,7 @@ def update_user(uid):
|
|||||||
user = request.get_json()
|
user = request.get_json()
|
||||||
success = True
|
success = True
|
||||||
status_code = 200
|
status_code = 200
|
||||||
|
users_dict[uid] = user
|
||||||
else:
|
else:
|
||||||
success = False
|
success = False
|
||||||
status_code = 404
|
status_code = 404
|
||||||
|
|||||||
@@ -20,14 +20,18 @@
|
|||||||
- token: content.token
|
- token: content.token
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: create user which does not exist
|
name: reset all users
|
||||||
variable_binds:
|
api: reset_all($token)
|
||||||
- user_name: "user1"
|
|
||||||
- user_password: "123456"
|
|
||||||
api: create_user(1000, $user_name, $user_password, $token)
|
|
||||||
validators:
|
validators:
|
||||||
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
- {"check": "status_code", "expected": 200}
|
||||||
- {"check": "content.success", "comparator": "eq", "expected": true}
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get user that does not exist
|
||||||
|
api: get_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 404}
|
||||||
|
- {"check": "content.success", "expected": false}
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
@@ -36,5 +40,79 @@
|
|||||||
- user_password: "123456"
|
- user_password: "123456"
|
||||||
api: create_user(1000, $user_name, $user_password, $token)
|
api: create_user(1000, $user_name, $user_password, $token)
|
||||||
validators:
|
validators:
|
||||||
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
- {"check": "status_code", "expected": 201}
|
||||||
- {"check": "content.success", "comparator": "eq", "expected": false}
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get user that has been created
|
||||||
|
api: get_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
- {"check": "content.data.password", "expected": "123456"}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: create user which exists
|
||||||
|
variable_binds:
|
||||||
|
- user_name: "user1"
|
||||||
|
- user_password: "123456"
|
||||||
|
api: create_user(1000, $user_name, $user_password, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 500}
|
||||||
|
- {"check": "content.success", "expected": false}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: update user which exists
|
||||||
|
variable_binds:
|
||||||
|
- user_name: "user1"
|
||||||
|
- user_password: "654321"
|
||||||
|
api: update_user(1000, $user_name, $user_password, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get user that has been created
|
||||||
|
api: get_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
- {"check": "content.data.password", "expected": "654321"}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get users
|
||||||
|
api: get_users($token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.count", "expected": 1}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: delete user that exists
|
||||||
|
api: delete_user(1000, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get users
|
||||||
|
api: get_users($token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.count", "expected": 0}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: create user which has been deleted
|
||||||
|
variable_binds:
|
||||||
|
- user_name: "user1"
|
||||||
|
- user_password: "123456"
|
||||||
|
api: create_user(1000, $user_name, $user_password, $token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 201}
|
||||||
|
- {"check": "content.success", "expected": true}
|
||||||
|
|
||||||
|
- test:
|
||||||
|
name: get users
|
||||||
|
api: get_users($token)
|
||||||
|
validators:
|
||||||
|
- {"check": "status_code", "expected": 200}
|
||||||
|
- {"check": "content.count", "expected": 1}
|
||||||
|
|||||||
Reference in New Issue
Block a user