mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-07 00:17:37 +08:00
tests: add demo
This commit is contained in:
@@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"config": {
|
||||||
|
"name": "demo with complex mechanisms",
|
||||||
|
"base_url": "https://postman-echo.com",
|
||||||
|
"variables": {
|
||||||
|
"a": 12.3,
|
||||||
|
"b": 3.45,
|
||||||
|
"n": 5,
|
||||||
|
"varFoo1": "${gen_random_string($n)}",
|
||||||
|
"varFoo2": "${max($a, $b)}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"teststeps": [
|
||||||
|
{
|
||||||
|
"name": "get with params",
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "/get",
|
||||||
|
"params": {
|
||||||
|
"foo1": "$varFoo1",
|
||||||
|
"foo2": "$varFoo2"
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": "HttpBoomer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"variables": {
|
||||||
|
"b": 34.5,
|
||||||
|
"n": 3,
|
||||||
|
"varFoo2": "${max($a, $b)}"
|
||||||
|
},
|
||||||
|
"extract": {
|
||||||
|
"varFoo1": "body.args.foo1"
|
||||||
|
},
|
||||||
|
"validate": [
|
||||||
|
{
|
||||||
|
"check": "status_code",
|
||||||
|
"assert": "equals",
|
||||||
|
"expect": 200,
|
||||||
|
"msg": "check response status code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"check": "headers.\"Content-Type\"",
|
||||||
|
"assert": "startswith",
|
||||||
|
"expect": "application/json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"check": "body.args.foo1",
|
||||||
|
"assert": "length_equals",
|
||||||
|
"expect": 5,
|
||||||
|
"msg": "check args foo1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"check": "$varFoo1",
|
||||||
|
"assert": "length_equals",
|
||||||
|
"expect": 5,
|
||||||
|
"msg": "check args foo1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"check": "body.args.foo2",
|
||||||
|
"assert": "equals",
|
||||||
|
"expect": "34.5",
|
||||||
|
"msg": "check args foo2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "post json data",
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"url": "/post",
|
||||||
|
"json": {
|
||||||
|
"foo1": "$varFoo1",
|
||||||
|
"foo2": "${max($a, $b)}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"validate": [
|
||||||
|
{
|
||||||
|
"check": "status_code",
|
||||||
|
"assert": "equals",
|
||||||
|
"expect": 200,
|
||||||
|
"msg": "check status code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"check": "body.json.foo1",
|
||||||
|
"assert": "length_equals",
|
||||||
|
"expect": 5,
|
||||||
|
"msg": "check args foo1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"check": "body.json.foo2",
|
||||||
|
"assert": "equals",
|
||||||
|
"expect": 12.3,
|
||||||
|
"msg": "check args foo2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
config:
|
||||||
|
name: demo with complex mechanisms
|
||||||
|
base_url: https://postman-echo.com
|
||||||
|
variables:
|
||||||
|
a: 12.3
|
||||||
|
b: 3.45
|
||||||
|
"n": 5
|
||||||
|
varFoo1: ${gen_random_string($n)}
|
||||||
|
varFoo2: ${max($a, $b)}
|
||||||
|
teststeps:
|
||||||
|
- name: get with params
|
||||||
|
request:
|
||||||
|
method: GET
|
||||||
|
url: /get
|
||||||
|
params:
|
||||||
|
foo1: $varFoo1
|
||||||
|
foo2: $varFoo2
|
||||||
|
headers:
|
||||||
|
User-Agent: HttpBoomer
|
||||||
|
variables:
|
||||||
|
b: 34.5
|
||||||
|
"n": 3
|
||||||
|
varFoo2: ${max($a, $b)}
|
||||||
|
extract:
|
||||||
|
varFoo1: body.args.foo1
|
||||||
|
validate:
|
||||||
|
- check: status_code
|
||||||
|
assert: equals
|
||||||
|
expect: 200
|
||||||
|
msg: check response status code
|
||||||
|
- check: headers."Content-Type"
|
||||||
|
assert: startswith
|
||||||
|
expect: application/json
|
||||||
|
- check: body.args.foo1
|
||||||
|
assert: length_equals
|
||||||
|
expect: 5
|
||||||
|
msg: check args foo1
|
||||||
|
- check: $varFoo1
|
||||||
|
assert: length_equals
|
||||||
|
expect: 5
|
||||||
|
msg: check args foo1
|
||||||
|
- check: body.args.foo2
|
||||||
|
assert: equals
|
||||||
|
expect: "34.5"
|
||||||
|
msg: check args foo2
|
||||||
|
- name: post json data
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: /post
|
||||||
|
json:
|
||||||
|
foo1: $varFoo1
|
||||||
|
foo2: ${max($a, $b)}
|
||||||
|
validate:
|
||||||
|
- check: status_code
|
||||||
|
assert: equals
|
||||||
|
expect: 200
|
||||||
|
msg: check status code
|
||||||
|
- check: body.json.foo1
|
||||||
|
assert: length_equals
|
||||||
|
expect: 5
|
||||||
|
msg: check args foo1
|
||||||
|
- check: body.json.foo2
|
||||||
|
assert: equals
|
||||||
|
expect: 12.3
|
||||||
|
msg: check args foo2
|
||||||
Reference in New Issue
Block a user