mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
change: update unit tests for removing v1 format
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
- config:
|
||||
config:
|
||||
name: "bugfix testcases."
|
||||
base_url: http://127.0.0.1:5000
|
||||
|
||||
- test:
|
||||
teststeps:
|
||||
-
|
||||
name: bugfix type_match #84
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
- config:
|
||||
config:
|
||||
name: basic test with httpbin
|
||||
base_url: https://httpbin.org/
|
||||
verify: False
|
||||
|
||||
- test:
|
||||
teststeps:
|
||||
-
|
||||
name: headers
|
||||
request:
|
||||
url: /headers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- config:
|
||||
config:
|
||||
name: "123t$var_a"
|
||||
variables:
|
||||
var_a: 1
|
||||
@@ -8,7 +8,8 @@
|
||||
var_e: $var_d
|
||||
PROJECT_KEY: ${ENV(PROJECT_KEY)}
|
||||
|
||||
- test:
|
||||
teststeps:
|
||||
-
|
||||
name: testcase1-$var_a
|
||||
request:
|
||||
url: /api1
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
- test:
|
||||
config:
|
||||
name: xxx
|
||||
|
||||
teststeps:
|
||||
-
|
||||
name: get token
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/get-token
|
||||
@@ -25,7 +29,7 @@
|
||||
- {"check": "status_code", "comparator": "sum_status_code", "expect": 2}
|
||||
- sum_status_code: ["status_code", 2]
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which does not exist
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
@@ -47,7 +51,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which existed
|
||||
times: 2
|
||||
request:
|
||||
@@ -67,7 +71,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which existed (skip unconditionally)
|
||||
skip: skip this test unconditionally
|
||||
times: 2
|
||||
@@ -88,7 +92,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which existed (skip if condition)
|
||||
skipIf: ${skip_test_in_production_env()}
|
||||
times: 2
|
||||
@@ -109,7 +113,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which existed (skip unless condition)
|
||||
skipUnless: ${skip_test_in_production_env()}
|
||||
times: 2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
- config:
|
||||
config:
|
||||
name: "create user testcases."
|
||||
variables:
|
||||
user_agent: 'iOS/10.3'
|
||||
@@ -7,7 +7,8 @@
|
||||
app_version: '2.8.6'
|
||||
base_url: ${get_base_url()}
|
||||
|
||||
- test:
|
||||
teststeps:
|
||||
-
|
||||
name: get token
|
||||
request:
|
||||
url: /api/get-token
|
||||
@@ -25,7 +26,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
||||
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which does not exist
|
||||
variables:
|
||||
user_name: "user1"
|
||||
@@ -44,7 +45,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which does not exist
|
||||
request:
|
||||
url: /api/users/1000
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
[
|
||||
{
|
||||
"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": "5188962c489d1a35effa99e9346dd5efd4fdabad"
|
||||
}
|
||||
},
|
||||
"variables": [
|
||||
{"expect_status_code": 200},
|
||||
{"token_len": 16}
|
||||
],
|
||||
"extract": {
|
||||
"token": "content.token"
|
||||
},
|
||||
"validate": [
|
||||
{"check": "status_code", "comparator": "eq", "expect": 200},
|
||||
{"eq": ["status_code", "$expect_status_code"]},
|
||||
{"check": "$token", "comparator": "len_eq", "expect": 16},
|
||||
{"len_eq": ["$token", "$token_len"]},
|
||||
{"len_eq": ["content.token", 16]},
|
||||
{"check": "status_code", "comparator": "sum_status_code", "expect": 2},
|
||||
{"sum_status_code": ["status_code", 2]}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "create user which does not exist",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/2000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"device_sn": "HZfFBh6tU59EdXJ",
|
||||
"token": "$token"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 201]},
|
||||
{"eq": ["content.success", true]},
|
||||
{"check": "status_code", "comparator": "eq", "expect": 201},
|
||||
{"sum_status_code": ["status_code", 3]},
|
||||
{"check": "content.success", "comparator": "eq", "expect": true}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"test": {
|
||||
"name": "create user which existed",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:5000/api/users/2000",
|
||||
"method": "POST",
|
||||
"headers": {
|
||||
"content-type": "application/json",
|
||||
"device_sn": "HZfFBh6tU59EdXJ",
|
||||
"token": "$token"
|
||||
},
|
||||
"json": {
|
||||
"name": "user1",
|
||||
"password": "123456"
|
||||
}
|
||||
},
|
||||
"validate": [
|
||||
{"eq": ["status_code", 500]},
|
||||
{"eq": ["content.success", false]},
|
||||
{"check": "status_code", "comparator": "eq", "expect": 500},
|
||||
{"sum_status_code": ["status_code", 5]},
|
||||
{"check": "content.success", "comparator": "eq", "expect": false}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,67 +0,0 @@
|
||||
- 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: 5188962c489d1a35effa99e9346dd5efd4fdabad
|
||||
variables:
|
||||
expect_status_code: 200
|
||||
token_len: 16
|
||||
extract:
|
||||
token: content.token
|
||||
validate:
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
||||
- eq: ["status_code", $expect_status_code]
|
||||
- {"check": "$token", "comparator": "len_eq", "expect": 16}
|
||||
- len_eq: ["$token", $token_len]
|
||||
- len_eq: ["content.token", 16]
|
||||
- {"check": "status_code", "comparator": "sum_status_code", "expect": 2}
|
||||
- sum_status_code: ["status_code", 2]
|
||||
|
||||
- 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
|
||||
device_sn: 'HZfFBh6tU59EdXJ'
|
||||
token: $token
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
extract:
|
||||
success: content.success
|
||||
validate:
|
||||
- eq: ["status_code", 201]
|
||||
- sum_status_code: ["status_code", 3]
|
||||
- eq: ["$success", True]
|
||||
- eq: ["abc$success", "abcTrue"]
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||
|
||||
- test:
|
||||
name: create user which existed
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
device_sn: 'HZfFBh6tU59EdXJ'
|
||||
token: $token
|
||||
json:
|
||||
name: "user1"
|
||||
password: "123456"
|
||||
validate:
|
||||
- "eq": ["status_code", 500]
|
||||
- sum_status_code: ["status_code", 5]
|
||||
- "eq": ["content.success", false]
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||
@@ -1,4 +1,4 @@
|
||||
- config:
|
||||
config:
|
||||
name: "user management testcase."
|
||||
variables:
|
||||
user_agent: 'iOS/10.3'
|
||||
@@ -9,7 +9,8 @@
|
||||
export:
|
||||
- token
|
||||
|
||||
- test:
|
||||
teststeps:
|
||||
-
|
||||
name: get token with $user_agent, $app_version
|
||||
api: api/get_token.yml
|
||||
extract:
|
||||
@@ -19,7 +20,7 @@
|
||||
- "len_eq": ["content.token", 16]
|
||||
- "contains": [{"a": 1, "b": 2}, "b"]
|
||||
|
||||
- test:
|
||||
-
|
||||
name: reset all users
|
||||
api: api/reset_all.yml
|
||||
variables:
|
||||
@@ -28,7 +29,7 @@
|
||||
- {"check": "status_code", "expect": 200}
|
||||
- {"check": "content.success", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: get user that does not exist
|
||||
api: api/get_user.yml
|
||||
variables:
|
||||
@@ -38,7 +39,7 @@
|
||||
- {"check": "status_code", "expect": 404}
|
||||
- {"check": "content.success", "expect": false}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which does not exist
|
||||
variables:
|
||||
uid: 1000
|
||||
@@ -50,7 +51,7 @@
|
||||
- {"check": "status_code", "expect": 201}
|
||||
- {"check": "content.success", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: get user that has been created
|
||||
api: api/get_user.yml
|
||||
variables:
|
||||
@@ -61,7 +62,7 @@
|
||||
- {"check": "content.success", "expect": true}
|
||||
- {"check": "content.data.password", "expect": "123456"}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which exists
|
||||
variables:
|
||||
uid: 1000
|
||||
@@ -73,7 +74,7 @@
|
||||
- {"check": "status_code", "expect": 500}
|
||||
- {"check": "content.success", "expect": false}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: update user which exists
|
||||
variables:
|
||||
uid: 1000
|
||||
@@ -85,7 +86,7 @@
|
||||
- {"check": "status_code", "expect": 200}
|
||||
- {"check": "content.success", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: get user that has been updated
|
||||
api: api/get_user.yml
|
||||
variables:
|
||||
@@ -96,7 +97,7 @@
|
||||
- {"check": "content.success", "expect": true}
|
||||
- {"check": "content.data.password", "expect": "654321"}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: get users
|
||||
api: api/get_users.yml
|
||||
variables:
|
||||
@@ -105,7 +106,7 @@
|
||||
- {"check": "status_code", "expect": 200}
|
||||
- {"check": "content.count", "expect": 1}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: delete user that exists
|
||||
api: api/delete_user.yml
|
||||
variables:
|
||||
@@ -115,7 +116,7 @@
|
||||
- {"check": "status_code", "expect": 200}
|
||||
- {"check": "content.success", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: get users
|
||||
api: api/get_users.yml
|
||||
variables:
|
||||
@@ -124,7 +125,7 @@
|
||||
- {"check": "status_code", "expect": 200}
|
||||
- {"check": "content.count", "expect": 0}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which has been deleted
|
||||
variables:
|
||||
uid: 1000
|
||||
@@ -136,7 +137,7 @@
|
||||
- {"check": "status_code", "expect": 201}
|
||||
- {"check": "content.success", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: get users
|
||||
api: api/get_users.yml
|
||||
variables:
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
- config:
|
||||
config:
|
||||
name: "create user testcases."
|
||||
variables:
|
||||
device_sn: 'HZfFBh6tU59EdXJ'
|
||||
base_url: ${get_base_url()}
|
||||
|
||||
- test:
|
||||
teststeps:
|
||||
-
|
||||
name: get token
|
||||
variables:
|
||||
user_agent: 'iOS/10.3'
|
||||
@@ -28,7 +29,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
||||
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which does not exist
|
||||
variables:
|
||||
user_name: "user1"
|
||||
@@ -47,7 +48,7 @@
|
||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||
|
||||
- test:
|
||||
-
|
||||
name: create user which does not exist
|
||||
request:
|
||||
url: /api/users/1000
|
||||
|
||||
Reference in New Issue
Block a user