Files
httprunner/examples/postman_echo/request_methods/request_with_variables.yml
2020-07-30 11:32:30 +08:00

79 lines
2.1 KiB
YAML

config:
name: "request methods testcase with variables"
variables: ${get_testcase_config_variables()}
base_url: "https://postman-echo.com"
verify: False
teststeps:
-
name: get with params
variables:
foo1: bar11
foo2: bar21
request:
method: GET
url: /get
params:
foo1: $foo1
foo2: $foo2
headers:
User-Agent: HttpRunner/3.0
extract:
foo3: "body.args.foo2"
validate:
- eq: ["status_code", 200]
- eq: ["body.args.foo1", "bar11"]
- eq: ["body.args.foo2", "bar21"]
-
name: post raw text
variables:
foo1: "bar12"
foo3: "bar32"
request:
method: POST
url: /post
headers:
User-Agent: HttpRunner/3.0
Content-Type: "text/plain"
data: "This is expected to be sent back as part of response body: $foo1-$foo2-$foo3."
validate:
- eq: ["status_code", 200]
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-testcase_config_bar2-bar32."]
-
name: post form data
variables:
foo2: bar23
request:
method: POST
url: /post
headers:
User-Agent: HttpRunner/3.0
Content-Type: "application/x-www-form-urlencoded"
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
validate:
- eq: ["status_code", 200]
- eq: ["body.form.foo1", "testcase_config_bar1"]
- eq: ["body.form.foo2", "bar23"]
- eq: ["body.form.foo3", "bar21"]
-
name: post form data using json
variables:
foo2: bar23
jsondata:
foo1: $foo1
foo2: $foo2
foo3: $foo3
request:
method: POST
url: /post
headers:
User-Agent: HttpRunner/3.0
Content-Type: "application/json"
json: $jsondata
validate:
- eq: ["status_code", 200]
- eq: ["body.data.foo1", "testcase_config_bar1"]
- eq: ["body.data.foo2", "bar23"]
- eq: ["body.data.foo3", "bar21"]