mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
tests: update tests
This commit is contained in:
+53
-14
@@ -42,16 +42,20 @@ def create_scaffold(project_name):
|
|||||||
config:
|
config:
|
||||||
name: "request methods testcase with functions"
|
name: "request methods testcase with functions"
|
||||||
variables:
|
variables:
|
||||||
foo1: session_bar1
|
foo1: config_bar1
|
||||||
|
foo2: config_bar2
|
||||||
|
expect_foo1: config_bar1
|
||||||
|
expect_foo2: config_bar2
|
||||||
base_url: "https://postman-echo.com"
|
base_url: "https://postman-echo.com"
|
||||||
verify: False
|
verify: False
|
||||||
|
export: ["foo3"]
|
||||||
|
|
||||||
teststeps:
|
teststeps:
|
||||||
-
|
-
|
||||||
name: get with params
|
name: get with params
|
||||||
variables:
|
variables:
|
||||||
foo1: bar1
|
foo1: bar11
|
||||||
foo2: session_bar2
|
foo2: bar21
|
||||||
sum_v: "${sum_two(1, 2)}"
|
sum_v: "${sum_two(1, 2)}"
|
||||||
request:
|
request:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -63,43 +67,78 @@ teststeps:
|
|||||||
headers:
|
headers:
|
||||||
User-Agent: HttpRunner/${get_httprunner_version()}
|
User-Agent: HttpRunner/${get_httprunner_version()}
|
||||||
extract:
|
extract:
|
||||||
session_foo2: "body.args.foo2"
|
foo3: "body.args.foo2"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.args.foo1", "session_bar1"]
|
- eq: ["body.args.foo1", "bar11"]
|
||||||
- eq: ["body.args.sum_v", "3"]
|
- eq: ["body.args.sum_v", "3"]
|
||||||
- eq: ["body.args.foo2", "session_bar2"]
|
- eq: ["body.args.foo2", "bar21"]
|
||||||
-
|
-
|
||||||
name: post raw text
|
name: post raw text
|
||||||
variables:
|
variables:
|
||||||
foo1: "hello world"
|
foo1: "bar12"
|
||||||
foo3: "$session_foo2"
|
foo3: "bar32"
|
||||||
request:
|
request:
|
||||||
method: POST
|
method: POST
|
||||||
url: /post
|
url: /post
|
||||||
headers:
|
headers:
|
||||||
User-Agent: HttpRunner/${get_httprunner_version()}
|
User-Agent: HttpRunner/${get_httprunner_version()}
|
||||||
Content-Type: "text/plain"
|
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:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- 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:
|
||||||
|
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&foo3=$foo3"
|
||||||
|
validate:
|
||||||
|
- eq: ["status_code", 200]
|
||||||
|
- eq: ["body.form.foo1", "$expect_foo1"]
|
||||||
|
- eq: ["body.form.foo2", "bar23"]
|
||||||
|
- eq: ["body.form.foo3", "bar21"]
|
||||||
"""
|
"""
|
||||||
demo_testcase_with_ref_content = """
|
demo_testcase_with_ref_content = """
|
||||||
config:
|
config:
|
||||||
name: "request methods testcase: reference testcase"
|
name: "request methods testcase: reference testcase"
|
||||||
variables:
|
variables:
|
||||||
foo1: session_bar1
|
foo1: testsuite_config_bar1
|
||||||
|
expect_foo1: testsuite_config_bar1
|
||||||
|
expect_foo2: config_bar2
|
||||||
base_url: "https://postman-echo.com"
|
base_url: "https://postman-echo.com"
|
||||||
verify: False
|
verify: False
|
||||||
|
|
||||||
teststeps:
|
teststeps:
|
||||||
-
|
-
|
||||||
name: request with referenced testcase
|
name: request with functions
|
||||||
variables:
|
variables:
|
||||||
foo1: override_bar1
|
foo1: testcase_ref_bar1
|
||||||
# NOTICE: relative testcase path based on debugtalk.py
|
expect_foo1: testcase_ref_bar1
|
||||||
testcase: testcases/demo_testcase_request.yml
|
testcase: testcases/demo_testcase_request.yml
|
||||||
|
export:
|
||||||
|
- foo3
|
||||||
|
-
|
||||||
|
name: post form data
|
||||||
|
variables:
|
||||||
|
foo1: bar1
|
||||||
|
request:
|
||||||
|
method: POST
|
||||||
|
url: /post
|
||||||
|
headers:
|
||||||
|
User-Agent: HttpRunner/${get_httprunner_version()}
|
||||||
|
Content-Type: "application/x-www-form-urlencoded"
|
||||||
|
data: "foo1=$foo1&foo2=$foo3"
|
||||||
|
validate:
|
||||||
|
- eq: ["status_code", 200]
|
||||||
|
- eq: ["body.form.foo1", "bar1"]
|
||||||
|
- eq: ["body.form.foo2", "bar21"]
|
||||||
"""
|
"""
|
||||||
ignore_content = "\n".join(
|
ignore_content = "\n".join(
|
||||||
[".env", "reports/*", "__pycache__/*", "*.pyc", ".python-version", "logs/*"]
|
[".env", "reports/*", "__pycache__/*", "*.pyc", ".python-version", "logs/*"]
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
config:
|
config:
|
||||||
name: "request methods testcase with functions"
|
name: "request methods testcase with functions"
|
||||||
variables:
|
variables:
|
||||||
foo1: session_bar1
|
foo1: config_bar1
|
||||||
|
foo2: config_bar2
|
||||||
base_url: "https://postman-echo.com"
|
base_url: "https://postman-echo.com"
|
||||||
verify: False
|
verify: False
|
||||||
|
|
||||||
@@ -10,7 +11,6 @@ teststeps:
|
|||||||
name: get with params
|
name: get with params
|
||||||
variables:
|
variables:
|
||||||
foo1: bar1
|
foo1: bar1
|
||||||
foo2: session_bar2
|
|
||||||
sum_v: "${sum_two(1, 2)}"
|
sum_v: "${sum_two(1, 2)}"
|
||||||
request:
|
request:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -25,6 +25,6 @@ teststeps:
|
|||||||
session_foo2: "body.args.foo2"
|
session_foo2: "body.args.foo2"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.args.foo1", "session_bar1"]
|
- eq: ["body.args.foo1", "bar1"]
|
||||||
- eq: ["body.args.sum_v", "3"]
|
- eq: ["body.args.sum_v", "3"]
|
||||||
- eq: ["body.args.foo2", "session_bar2"]
|
- eq: ["body.args.foo2", "config_bar2"]
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
config:
|
config:
|
||||||
name: "reference testcase unittest for abnormal folder path"
|
name: "reference testcase unittest for abnormal folder path"
|
||||||
variables:
|
|
||||||
foo1: session_bar1
|
|
||||||
base_url: "https://postman-echo.com"
|
base_url: "https://postman-echo.com"
|
||||||
verify: False
|
verify: False
|
||||||
|
|
||||||
teststeps:
|
teststeps:
|
||||||
-
|
-
|
||||||
name: request with functions
|
name: request with functions
|
||||||
variables:
|
|
||||||
foo1: override_bar1
|
|
||||||
testcase: 1.yml
|
testcase: 1.yml
|
||||||
export:
|
export:
|
||||||
- session_foo2
|
- session_foo2
|
||||||
-
|
-
|
||||||
name: post form data
|
name: post form data
|
||||||
variables:
|
variables:
|
||||||
foo1: bar1
|
foo1: bar12
|
||||||
request:
|
request:
|
||||||
method: POST
|
method: POST
|
||||||
url: /post
|
url: /post
|
||||||
@@ -26,5 +22,5 @@ teststeps:
|
|||||||
data: "foo1=$foo1&foo2=$session_foo2"
|
data: "foo1=$foo1&foo2=$session_foo2"
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.form.foo1", "session_bar1"]
|
- eq: ["body.form.foo1", "bar12"]
|
||||||
- eq: ["body.form.foo2", "session_bar2"]
|
- eq: ["body.form.foo2", "config_bar2"]
|
||||||
|
|||||||
+1
-1
@@ -139,5 +139,5 @@ class TestUtils(unittest.TestCase):
|
|||||||
config_variables = {"base_url": "https://httpbin.org", "foo1": "bar111"}
|
config_variables = {"base_url": "https://httpbin.org", "foo1": "bar111"}
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
override_config_variables(step_variables, config_variables),
|
override_config_variables(step_variables, config_variables),
|
||||||
{"base_url": "https://httpbin.org", "foo1": "bar111"},
|
{"base_url": "https://httpbin.org", "foo1": "bar1"},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user