mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 12:27:59 +08:00
change testcase data structure, in order to distinguish config and test
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
-
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
|
||||
-
|
||||
variable_binds:
|
||||
- var: [1, 2, 3]
|
||||
variable_binds:
|
||||
- var: [1, 2, 3]
|
||||
|
||||
-
|
||||
variable_binds:
|
||||
- data: {'name': 'user', 'password': '123456'}
|
||||
variable_binds:
|
||||
- data: {'name': 'user', 'password': '123456'}
|
||||
|
||||
-
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
- token: $TOKEN
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
- token: $TOKEN
|
||||
|
||||
-
|
||||
function_binds:
|
||||
add_one: "lambda x: x + 1"
|
||||
add_two_nums: "lambda x, y: x + y"
|
||||
variable_binds:
|
||||
- add1: {"func": "add_one", "args": [2]}
|
||||
- sum2nums: {"func": "add_two_nums", "args": [2, 3]}
|
||||
function_binds:
|
||||
add_one: "lambda x: x + 1"
|
||||
add_two_nums: "lambda x, y: x + y"
|
||||
variable_binds:
|
||||
- add1: {"func": "add_one", "args": [2]}
|
||||
- sum2nums: {"func": "add_two_nums", "args": [2, 3]}
|
||||
|
||||
-
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: "{'name': 'user', 'password': '123456'}"
|
||||
- authorization: {"func": "gen_md5", "args": [$TOKEN, $data, $random]}
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: "{'name': 'user', 'password': '123456'}"
|
||||
- authorization: {"func": "gen_md5", "args": [$TOKEN, $data, $random]}
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
|
||||
-
|
||||
name: create user which does not exist
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["$TOKEN", "$data", "$random"]}
|
||||
- expected_status_code: 201
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
response:
|
||||
status_code: "${expected_status_code}"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["$TOKEN", "$data", "$random"]}
|
||||
- expected_status_code: 201
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
response:
|
||||
status_code: "${expected_status_code}"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
|
||||
-
|
||||
name: create user which does not exist
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["$TOKEN", "$data", "$random"]}
|
||||
- expected_status_code: 500
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
response:
|
||||
status_code: "${expected_status_code}"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["$TOKEN", "$data", "$random"]}
|
||||
- expected_status_code: 500
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
response:
|
||||
status_code: "${expected_status_code}"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
|
||||
@@ -1,53 +1,57 @@
|
||||
[
|
||||
{
|
||||
"name": "create user which does not exist",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"authorization": "a83de0ff8d2e896dbd8efb81ba14e17d",
|
||||
"random": "A2dEx"
|
||||
"test": {
|
||||
"name": "create user which does not exist",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"authorization": "a83de0ff8d2e896dbd8efb81ba14e17d",
|
||||
"random": "A2dEx"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status_code": 201,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"success": true,
|
||||
"msg": "user created successfully."
|
||||
"response": {
|
||||
"status_code": 201,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"success": true,
|
||||
"msg": "user created successfully."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "create user which existed",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"authorization": "a83de0ff8d2e896dbd8efb81ba14e17d",
|
||||
"random": "A2dEx"
|
||||
"test": {
|
||||
"name": "create user which existed",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"authorization": "a83de0ff8d2e896dbd8efb81ba14e17d",
|
||||
"random": "A2dEx"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status_code": 500,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body":{
|
||||
"success": false,
|
||||
"msg": "user already existed."
|
||||
"response": {
|
||||
"status_code": 500,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body":{
|
||||
"success": false,
|
||||
"msg": "user already existed."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
-
|
||||
name: create user which does not exist
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: a83de0ff8d2e896dbd8efb81ba14e17d
|
||||
random: A2dEx
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
response:
|
||||
status_code: 201
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: a83de0ff8d2e896dbd8efb81ba14e17d
|
||||
random: A2dEx
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
response:
|
||||
status_code: 201
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
|
||||
-
|
||||
name: create user which existed
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: a83de0ff8d2e896dbd8efb81ba14e17d
|
||||
random: A2dEx
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
response:
|
||||
status_code: 500
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: false
|
||||
msg: user already existed.
|
||||
- test:
|
||||
name: create user which existed
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: a83de0ff8d2e896dbd8efb81ba14e17d
|
||||
random: A2dEx
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
response:
|
||||
status_code: 500
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: false
|
||||
msg: user already existed.
|
||||
@@ -1,50 +1,54 @@
|
||||
[
|
||||
{
|
||||
"name": "create user which does not exist",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
"test": {
|
||||
"name": "create user which does not exist",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"cookies": {},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"cookies": {},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status_code": 201,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"success": true,
|
||||
"msg": "user created successfully."
|
||||
"response": {
|
||||
"status_code": 201,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body": {
|
||||
"success": true,
|
||||
"msg": "user created successfully."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "create user which existed",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
"test": {
|
||||
"name": "create user which existed",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"response": {
|
||||
"status_code": 500,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body":{
|
||||
"success": false,
|
||||
"msg": "user already existed."
|
||||
"response": {
|
||||
"status_code": 500,
|
||||
"headers": {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
"body":{
|
||||
"success": false,
|
||||
"msg": "user already existed."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-
|
||||
- test:
|
||||
name: create user which does not exist
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
@@ -16,7 +16,7 @@
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
|
||||
-
|
||||
- test:
|
||||
name: create user which existed
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
|
||||
Reference in New Issue
Block a user