mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
86 lines
2.1 KiB
YAML
86 lines
2.1 KiB
YAML
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: HttpRunnerPlus
|
|
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
|
|
body:
|
|
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
|
|
- name: post form data
|
|
request:
|
|
method: POST
|
|
url: /post
|
|
params:
|
|
foo1: $varFoo1
|
|
foo2: ${max($a, $b)}
|
|
validate:
|
|
- check: status_code
|
|
assert: equals
|
|
expect: 200
|
|
msg: check status code
|
|
- check: body.form.foo1
|
|
assert: length_equals
|
|
expect: 5
|
|
msg: check args foo1
|
|
- check: body.form.foo2
|
|
assert: equals
|
|
expect: "12.3"
|
|
msg: check args foo2
|