change: override variables

(1) testcase: session variables > step variables > config variables
(2) testsuite: testcase variables > config variables
(3) testsuite testcase variables > testcase config variables
This commit is contained in:
debugtalk
2020-06-08 16:11:06 +08:00
parent 9b0e60fa23
commit 915ac691ff
21 changed files with 207 additions and 116 deletions
@@ -1,17 +1,20 @@
config:
name: "request methods testcase with functions"
variables:
foo1: session_bar1
foo1: config_bar1
foo2: config_bar2
expect_foo1: config_bar1
expect_foo2: config_bar2
base_url: "https://postman-echo.com"
verify: False
export: ["session_foo2"]
export: ["foo3"]
teststeps:
-
name: get with params
variables:
foo1: bar1
foo2: session_bar2
foo1: bar11
foo2: bar21
sum_v: "${sum_two(1, 2)}"
request:
method: GET
@@ -23,40 +26,40 @@ teststeps:
headers:
User-Agent: HttpRunner/${get_httprunner_version()}
extract:
session_foo2: "body.args.foo2"
foo3: "body.args.foo2"
validate:
- eq: ["status_code", 200]
- eq: ["body.args.foo1", "session_bar1"]
- eq: ["body.args.foo1", "bar11"]
- eq: ["body.args.sum_v", "3"]
- eq: ["body.args.foo2", "session_bar2"]
- eq: ["body.args.foo2", "bar21"]
-
name: post raw text
variables:
foo1: "hello world"
foo3: "$session_foo2"
foo1: "bar12"
foo3: "bar32"
request:
method: POST
url: /post
headers:
User-Agent: HttpRunner/${get_httprunner_version()}
Content-Type: "text/plain"
data: "This is expected to be sent back as part of response body: $foo1-$foo3."
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: session_bar1-session_bar2."]
- eq: ["body.data", "This is expected to be sent back as part of response body: bar12-$expect_foo2-bar21."]
-
name: post form data
variables:
foo1: bar1
foo2: bar2
foo2: bar23
request:
method: POST
url: /post
headers:
User-Agent: HttpRunner/${get_httprunner_version()}
Content-Type: "application/x-www-form-urlencoded"
data: "foo1=$foo1&foo2=$foo2"
data: "foo1=$foo1&foo2=$foo2&foo3=$foo3"
validate:
- eq: ["status_code", 200]
- eq: ["body.form.foo1", "session_bar1"]
- eq: ["body.form.foo2", "bar2"]
- eq: ["body.form.foo1", "$expect_foo1"]
- eq: ["body.form.foo2", "bar23"]
- eq: ["body.form.foo3", "bar21"]