mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
@@ -39,7 +39,7 @@ To ensure the installation or upgrade is successful, you can execute command `at
|
||||
|
||||
```text
|
||||
$ ate -V
|
||||
ApiTestEngine version: 0.7.0
|
||||
ApiTestEngine version: 0.7.4
|
||||
```
|
||||
|
||||
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
|
||||
$ ate -V
|
||||
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.
|
||||
@@ -283,7 +283,8 @@ $ python main-locust -h
|
||||
- [《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 演进之路(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/
|
||||
[unittest]: https://docs.python.org/3/library/unittest.html
|
||||
|
||||
@@ -197,10 +197,9 @@ class Runner(object):
|
||||
try:
|
||||
result = self._run_testset(testset, mapping)
|
||||
assert result["success"]
|
||||
output.update(result["output"])
|
||||
except AssertionError:
|
||||
success = False
|
||||
finally:
|
||||
output.update(result["output"])
|
||||
|
||||
return {
|
||||
"success": success,
|
||||
|
||||
@@ -12,6 +12,7 @@ test_def_overall_dict = {
|
||||
"api": {},
|
||||
"suite": {}
|
||||
}
|
||||
testcases_cache_mapping = {}
|
||||
|
||||
|
||||
def extract_variables(content):
|
||||
@@ -149,16 +150,25 @@ def load_testcases_by_path(path):
|
||||
if not os.path.isabs(path):
|
||||
path = os.path.join(os.getcwd(), path)
|
||||
|
||||
if path in testcases_cache_mapping:
|
||||
return testcases_cache_mapping[path]
|
||||
|
||||
if os.path.isdir(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):
|
||||
testset = load_test_file(path)
|
||||
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):
|
||||
""" load testset file, get testset data structure.
|
||||
|
||||
@@ -24,3 +24,46 @@
|
||||
json:
|
||||
name: $user_name
|
||||
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,5 +1,4 @@
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
from functools import wraps
|
||||
|
||||
@@ -184,6 +183,7 @@ def update_user(uid):
|
||||
user = request.get_json()
|
||||
success = True
|
||||
status_code = 200
|
||||
users_dict[uid] = user
|
||||
else:
|
||||
success = False
|
||||
status_code = 404
|
||||
|
||||
@@ -20,14 +20,18 @@
|
||||
- token: content.token
|
||||
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
variable_binds:
|
||||
- user_name: "user1"
|
||||
- user_password: "123456"
|
||||
api: create_user(1000, $user_name, $user_password, $token)
|
||||
name: reset all users
|
||||
api: reset_all($token)
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": true}
|
||||
- {"check": "status_code", "expected": 200}
|
||||
- {"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:
|
||||
name: create user which does not exist
|
||||
@@ -36,5 +40,79 @@
|
||||
- user_password: "123456"
|
||||
api: create_user(1000, $user_name, $user_password, $token)
|
||||
validators:
|
||||
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expected": false}
|
||||
- {"check": "status_code", "expected": 201}
|
||||
- {"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