mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
change: update unit tests for removing v1 format
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
```
|
```
|
||||||
|
|
||||||
参考案例:[httprunner/tests/httpbin/upload.v2.yml][2]
|
参考案例:[httprunner/tests/httpbin/upload.yml][2]
|
||||||
|
|
||||||
[1]: https://toolbelt.readthedocs.io/en/latest/uploading-data.html
|
[1]: https://toolbelt.readthedocs.io/en/latest/uploading-data.html
|
||||||
[2]: https://github.com/httprunner/httprunner/blob/master/tests/httpbin/upload.v2.yml
|
[2]: https://github.com/httprunner/httprunner/blob/master/tests/httpbin/upload.yml
|
||||||
@@ -115,18 +115,6 @@ class TestSuiteLoader(unittest.TestCase):
|
|||||||
self.assertIn("teststeps", loaded_content)
|
self.assertIn("teststeps", loaded_content)
|
||||||
self.assertEqual(len(loaded_content["teststeps"]), 2)
|
self.assertEqual(len(loaded_content["teststeps"]), 2)
|
||||||
|
|
||||||
def test_load_test_file_testcase_v2(self):
|
|
||||||
for loaded_content in [
|
|
||||||
buildup.load_test_file("tests/testcases/setup.v2.yml"),
|
|
||||||
buildup.load_test_file("tests/testcases/setup.v2.json")
|
|
||||||
]:
|
|
||||||
self.assertEqual(loaded_content["type"], "testcase")
|
|
||||||
self.assertIn("path", loaded_content)
|
|
||||||
self.assertIn("config", loaded_content)
|
|
||||||
self.assertEqual(loaded_content["config"]["name"], "setup and reset all.")
|
|
||||||
self.assertIn("teststeps", loaded_content)
|
|
||||||
self.assertEqual(len(loaded_content["teststeps"]), 2)
|
|
||||||
|
|
||||||
def test_load_test_file_testsuite(self):
|
def test_load_test_file_testsuite(self):
|
||||||
for loaded_content in [
|
for loaded_content in [
|
||||||
buildup.load_test_file("tests/testsuites/create_users.yml"),
|
buildup.load_test_file("tests/testsuites/create_users.yml"),
|
||||||
@@ -143,22 +131,6 @@ class TestSuiteLoader(unittest.TestCase):
|
|||||||
"create user and check result."
|
"create user and check result."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_load_test_file_testsuite_v2(self):
|
|
||||||
for loaded_content in [
|
|
||||||
buildup.load_test_file("tests/testsuites/create_users.v2.yml"),
|
|
||||||
buildup.load_test_file("tests/testsuites/create_users.v2.json")
|
|
||||||
]:
|
|
||||||
self.assertEqual(loaded_content["type"], "testsuite")
|
|
||||||
|
|
||||||
testcases = loaded_content["testcases"]
|
|
||||||
self.assertEqual(len(testcases), 2)
|
|
||||||
self.assertIn('create user 1000 and check result.', testcases)
|
|
||||||
self.assertIn('testcase_def', testcases["create user 1000 and check result."])
|
|
||||||
self.assertEqual(
|
|
||||||
testcases["create user 1000 and check result."]["testcase_def"]["config"]["name"],
|
|
||||||
"create user and check result."
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_load_tests_api_file(self):
|
def test_load_tests_api_file(self):
|
||||||
path = os.path.join(
|
path = os.path.join(
|
||||||
os.getcwd(), 'tests/api/create_user.yml')
|
os.getcwd(), 'tests/api/create_user.yml')
|
||||||
@@ -168,26 +140,6 @@ class TestSuiteLoader(unittest.TestCase):
|
|||||||
self.assertEqual(len(api_list), 1)
|
self.assertEqual(len(api_list), 1)
|
||||||
self.assertEqual(api_list[0]["request"]["url"], "/api/users/$uid")
|
self.assertEqual(api_list[0]["request"]["url"], "/api/users/$uid")
|
||||||
|
|
||||||
def test_load_tests_testcase_file(self):
|
|
||||||
# absolute file path
|
|
||||||
path = os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
|
|
||||||
tests_mapping = loader.load_cases(path)
|
|
||||||
project_mapping = tests_mapping["project_mapping"]
|
|
||||||
testcases_list = tests_mapping["testcases"]
|
|
||||||
self.assertEqual(len(testcases_list), 1)
|
|
||||||
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
|
|
||||||
self.assertIn("get_sign", project_mapping["functions"])
|
|
||||||
|
|
||||||
# relative file path
|
|
||||||
path = 'tests/data/demo_testcase_hardcode.yml'
|
|
||||||
tests_mapping = loader.load_cases(path)
|
|
||||||
project_mapping = tests_mapping["project_mapping"]
|
|
||||||
testcases_list = tests_mapping["testcases"]
|
|
||||||
self.assertEqual(len(testcases_list), 1)
|
|
||||||
self.assertEqual(len(testcases_list[0]["teststeps"]), 3)
|
|
||||||
self.assertIn("get_sign", project_mapping["functions"])
|
|
||||||
|
|
||||||
def test_load_tests_testcase_file_2(self):
|
def test_load_tests_testcase_file_2(self):
|
||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'tests/data/demo_testcase.yml')
|
os.getcwd(), 'tests/data/demo_testcase.yml')
|
||||||
|
|||||||
@@ -62,28 +62,6 @@ class TestFileLoader(unittest.TestCase):
|
|||||||
with self.assertRaises(exceptions.FileNotFound):
|
with self.assertRaises(exceptions.FileNotFound):
|
||||||
load.load_file(testcase_file_path)
|
load.load_file(testcase_file_path)
|
||||||
|
|
||||||
def test_load_json_testcases(self):
|
|
||||||
testcase_file_path = os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
|
|
||||||
testcases = load.load_file(testcase_file_path)
|
|
||||||
self.assertEqual(len(testcases), 3)
|
|
||||||
test = testcases[0]["test"]
|
|
||||||
self.assertIn('name', test)
|
|
||||||
self.assertIn('request', test)
|
|
||||||
self.assertIn('url', test['request'])
|
|
||||||
self.assertIn('method', test['request'])
|
|
||||||
|
|
||||||
def test_load_yaml_testcases(self):
|
|
||||||
testcase_file_path = os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml')
|
|
||||||
testcases = load.load_file(testcase_file_path)
|
|
||||||
self.assertEqual(len(testcases), 3)
|
|
||||||
test = testcases[0]["test"]
|
|
||||||
self.assertIn('name', test)
|
|
||||||
self.assertIn('request', test)
|
|
||||||
self.assertIn('url', test['request'])
|
|
||||||
self.assertIn('method', test['request'])
|
|
||||||
|
|
||||||
def test_load_csv_file_one_parameter(self):
|
def test_load_csv_file_one_parameter(self):
|
||||||
csv_file_path = os.path.join(
|
csv_file_path = os.path.join(
|
||||||
os.getcwd(), 'tests/data/user_agent.csv')
|
os.getcwd(), 'tests/data/user_agent.csv')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
"description": "httprunner testcase schema v2 definition",
|
"description": "httprunner testcase schema definition",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"teststep": {
|
"teststep": {
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "testcase.schema.v2.json#/definitions/teststep"
|
"$ref": "testcase.schema.json#/definitions/teststep"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
"description": "httprunner testsuite schema v2 definition",
|
"description": "httprunner testsuite schema definition",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"testcase": {
|
"testcase": {
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "testsuite.schema.v2.json#/definitions/testcase"
|
"$ref": "testsuite.schema.json#/definitions/testcase"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
- config:
|
config:
|
||||||
name: "bugfix testcases."
|
name: "bugfix testcases."
|
||||||
base_url: http://127.0.0.1:5000
|
base_url: http://127.0.0.1:5000
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: bugfix type_match #84
|
name: bugfix type_match #84
|
||||||
request:
|
request:
|
||||||
url: http://127.0.0.1:5000/api/users/1000
|
url: http://127.0.0.1:5000/api/users/1000
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
- config:
|
config:
|
||||||
name: basic test with httpbin
|
name: basic test with httpbin
|
||||||
base_url: https://httpbin.org/
|
base_url: https://httpbin.org/
|
||||||
verify: False
|
verify: False
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: headers
|
name: headers
|
||||||
request:
|
request:
|
||||||
url: /headers
|
url: /headers
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
- config:
|
config:
|
||||||
name: "123t$var_a"
|
name: "123t$var_a"
|
||||||
variables:
|
variables:
|
||||||
var_a: 1
|
var_a: 1
|
||||||
@@ -8,7 +8,8 @@
|
|||||||
var_e: $var_d
|
var_e: $var_d
|
||||||
PROJECT_KEY: ${ENV(PROJECT_KEY)}
|
PROJECT_KEY: ${ENV(PROJECT_KEY)}
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: testcase1-$var_a
|
name: testcase1-$var_a
|
||||||
request:
|
request:
|
||||||
url: /api1
|
url: /api1
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
- test:
|
config:
|
||||||
|
name: xxx
|
||||||
|
|
||||||
|
teststeps:
|
||||||
|
-
|
||||||
name: get token
|
name: get token
|
||||||
request:
|
request:
|
||||||
url: http://127.0.0.1:5000/api/get-token
|
url: http://127.0.0.1:5000/api/get-token
|
||||||
@@ -25,7 +29,7 @@
|
|||||||
- {"check": "status_code", "comparator": "sum_status_code", "expect": 2}
|
- {"check": "status_code", "comparator": "sum_status_code", "expect": 2}
|
||||||
- sum_status_code: ["status_code", 2]
|
- sum_status_code: ["status_code", 2]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
request:
|
request:
|
||||||
url: http://127.0.0.1:5000/api/users/1000
|
url: http://127.0.0.1:5000/api/users/1000
|
||||||
@@ -47,7 +51,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which existed
|
name: create user which existed
|
||||||
times: 2
|
times: 2
|
||||||
request:
|
request:
|
||||||
@@ -67,7 +71,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which existed (skip unconditionally)
|
name: create user which existed (skip unconditionally)
|
||||||
skip: skip this test unconditionally
|
skip: skip this test unconditionally
|
||||||
times: 2
|
times: 2
|
||||||
@@ -88,7 +92,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which existed (skip if condition)
|
name: create user which existed (skip if condition)
|
||||||
skipIf: ${skip_test_in_production_env()}
|
skipIf: ${skip_test_in_production_env()}
|
||||||
times: 2
|
times: 2
|
||||||
@@ -109,7 +113,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
- {"check": "content.success", "comparator": "eq", "expect": false}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which existed (skip unless condition)
|
name: create user which existed (skip unless condition)
|
||||||
skipUnless: ${skip_test_in_production_env()}
|
skipUnless: ${skip_test_in_production_env()}
|
||||||
times: 2
|
times: 2
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
- config:
|
config:
|
||||||
name: "create user testcases."
|
name: "create user testcases."
|
||||||
variables:
|
variables:
|
||||||
user_agent: 'iOS/10.3'
|
user_agent: 'iOS/10.3'
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
app_version: '2.8.6'
|
app_version: '2.8.6'
|
||||||
base_url: ${get_base_url()}
|
base_url: ${get_base_url()}
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: get token
|
name: get token
|
||||||
request:
|
request:
|
||||||
url: /api/get-token
|
url: /api/get-token
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
||||||
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
|
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
variables:
|
variables:
|
||||||
user_name: "user1"
|
user_name: "user1"
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
request:
|
request:
|
||||||
url: /api/users/1000
|
url: /api/users/1000
|
||||||
|
|||||||
@@ -1,87 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"test": {
|
|
||||||
"name": "get token",
|
|
||||||
"request": {
|
|
||||||
"url": "http://127.0.0.1:5000/api/get-token",
|
|
||||||
"method": "POST",
|
|
||||||
"headers": {
|
|
||||||
"content-type": "application/json",
|
|
||||||
"user_agent": "iOS/10.3",
|
|
||||||
"device_sn": "HZfFBh6tU59EdXJ",
|
|
||||||
"os_platform": "ios",
|
|
||||||
"app_version": "2.8.6"
|
|
||||||
},
|
|
||||||
"json": {
|
|
||||||
"sign": "5188962c489d1a35effa99e9346dd5efd4fdabad"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"variables": [
|
|
||||||
{"expect_status_code": 200},
|
|
||||||
{"token_len": 16}
|
|
||||||
],
|
|
||||||
"extract": {
|
|
||||||
"token": "content.token"
|
|
||||||
},
|
|
||||||
"validate": [
|
|
||||||
{"check": "status_code", "comparator": "eq", "expect": 200},
|
|
||||||
{"eq": ["status_code", "$expect_status_code"]},
|
|
||||||
{"check": "$token", "comparator": "len_eq", "expect": 16},
|
|
||||||
{"len_eq": ["$token", "$token_len"]},
|
|
||||||
{"len_eq": ["content.token", 16]},
|
|
||||||
{"check": "status_code", "comparator": "sum_status_code", "expect": 2},
|
|
||||||
{"sum_status_code": ["status_code", 2]}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"test": {
|
|
||||||
"name": "create user which does not exist",
|
|
||||||
"request": {
|
|
||||||
"url": "http://127.0.0.1:5000/api/users/2000",
|
|
||||||
"method": "POST",
|
|
||||||
"headers": {
|
|
||||||
"content-type": "application/json",
|
|
||||||
"device_sn": "HZfFBh6tU59EdXJ",
|
|
||||||
"token": "$token"
|
|
||||||
},
|
|
||||||
"json": {
|
|
||||||
"name": "user1",
|
|
||||||
"password": "123456"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"validate": [
|
|
||||||
{"eq": ["status_code", 201]},
|
|
||||||
{"eq": ["content.success", true]},
|
|
||||||
{"check": "status_code", "comparator": "eq", "expect": 201},
|
|
||||||
{"sum_status_code": ["status_code", 3]},
|
|
||||||
{"check": "content.success", "comparator": "eq", "expect": true}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"test": {
|
|
||||||
"name": "create user which existed",
|
|
||||||
"request": {
|
|
||||||
"url": "http://127.0.0.1:5000/api/users/2000",
|
|
||||||
"method": "POST",
|
|
||||||
"headers": {
|
|
||||||
"content-type": "application/json",
|
|
||||||
"device_sn": "HZfFBh6tU59EdXJ",
|
|
||||||
"token": "$token"
|
|
||||||
},
|
|
||||||
"json": {
|
|
||||||
"name": "user1",
|
|
||||||
"password": "123456"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"validate": [
|
|
||||||
{"eq": ["status_code", 500]},
|
|
||||||
{"eq": ["content.success", false]},
|
|
||||||
{"check": "status_code", "comparator": "eq", "expect": 500},
|
|
||||||
{"sum_status_code": ["status_code", 5]},
|
|
||||||
{"check": "content.success", "comparator": "eq", "expect": false}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
- test:
|
|
||||||
name: get token
|
|
||||||
request:
|
|
||||||
url: http://127.0.0.1:5000/api/get-token
|
|
||||||
method: POST
|
|
||||||
headers:
|
|
||||||
Content-Type: application/json
|
|
||||||
user_agent: 'iOS/10.3'
|
|
||||||
device_sn: 'HZfFBh6tU59EdXJ'
|
|
||||||
os_platform: 'ios'
|
|
||||||
app_version: '2.8.6'
|
|
||||||
json:
|
|
||||||
sign: 5188962c489d1a35effa99e9346dd5efd4fdabad
|
|
||||||
variables:
|
|
||||||
expect_status_code: 200
|
|
||||||
token_len: 16
|
|
||||||
extract:
|
|
||||||
token: content.token
|
|
||||||
validate:
|
|
||||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
|
||||||
- eq: ["status_code", $expect_status_code]
|
|
||||||
- {"check": "$token", "comparator": "len_eq", "expect": 16}
|
|
||||||
- len_eq: ["$token", $token_len]
|
|
||||||
- len_eq: ["content.token", 16]
|
|
||||||
- {"check": "status_code", "comparator": "sum_status_code", "expect": 2}
|
|
||||||
- sum_status_code: ["status_code", 2]
|
|
||||||
|
|
||||||
- test:
|
|
||||||
name: create user which does not exist
|
|
||||||
request:
|
|
||||||
url: http://127.0.0.1:5000/api/users/1000
|
|
||||||
method: POST
|
|
||||||
headers:
|
|
||||||
Content-Type: application/json
|
|
||||||
device_sn: 'HZfFBh6tU59EdXJ'
|
|
||||||
token: $token
|
|
||||||
json:
|
|
||||||
name: "user1"
|
|
||||||
password: "123456"
|
|
||||||
extract:
|
|
||||||
success: content.success
|
|
||||||
validate:
|
|
||||||
- eq: ["status_code", 201]
|
|
||||||
- sum_status_code: ["status_code", 3]
|
|
||||||
- eq: ["$success", True]
|
|
||||||
- eq: ["abc$success", "abcTrue"]
|
|
||||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
|
||||||
|
|
||||||
- test:
|
|
||||||
name: create user which existed
|
|
||||||
request:
|
|
||||||
url: http://127.0.0.1:5000/api/users/1000
|
|
||||||
method: POST
|
|
||||||
headers:
|
|
||||||
Content-Type: application/json
|
|
||||||
device_sn: 'HZfFBh6tU59EdXJ'
|
|
||||||
token: $token
|
|
||||||
json:
|
|
||||||
name: "user1"
|
|
||||||
password: "123456"
|
|
||||||
validate:
|
|
||||||
- "eq": ["status_code", 500]
|
|
||||||
- sum_status_code: ["status_code", 5]
|
|
||||||
- "eq": ["content.success", false]
|
|
||||||
- {"check": "status_code", "comparator": "eq", "expect": 500}
|
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": false}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
- config:
|
config:
|
||||||
name: "user management testcase."
|
name: "user management testcase."
|
||||||
variables:
|
variables:
|
||||||
user_agent: 'iOS/10.3'
|
user_agent: 'iOS/10.3'
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
export:
|
export:
|
||||||
- token
|
- token
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: get token with $user_agent, $app_version
|
name: get token with $user_agent, $app_version
|
||||||
api: api/get_token.yml
|
api: api/get_token.yml
|
||||||
extract:
|
extract:
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
- "len_eq": ["content.token", 16]
|
- "len_eq": ["content.token", 16]
|
||||||
- "contains": [{"a": 1, "b": 2}, "b"]
|
- "contains": [{"a": 1, "b": 2}, "b"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: reset all users
|
name: reset all users
|
||||||
api: api/reset_all.yml
|
api: api/reset_all.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
- {"check": "status_code", "expect": 200}
|
- {"check": "status_code", "expect": 200}
|
||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get user that does not exist
|
name: get user that does not exist
|
||||||
api: api/get_user.yml
|
api: api/get_user.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -38,7 +39,7 @@
|
|||||||
- {"check": "status_code", "expect": 404}
|
- {"check": "status_code", "expect": 404}
|
||||||
- {"check": "content.success", "expect": false}
|
- {"check": "content.success", "expect": false}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
variables:
|
variables:
|
||||||
uid: 1000
|
uid: 1000
|
||||||
@@ -50,7 +51,7 @@
|
|||||||
- {"check": "status_code", "expect": 201}
|
- {"check": "status_code", "expect": 201}
|
||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get user that has been created
|
name: get user that has been created
|
||||||
api: api/get_user.yml
|
api: api/get_user.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
- {"check": "content.data.password", "expect": "123456"}
|
- {"check": "content.data.password", "expect": "123456"}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which exists
|
name: create user which exists
|
||||||
variables:
|
variables:
|
||||||
uid: 1000
|
uid: 1000
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
- {"check": "status_code", "expect": 500}
|
- {"check": "status_code", "expect": 500}
|
||||||
- {"check": "content.success", "expect": false}
|
- {"check": "content.success", "expect": false}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: update user which exists
|
name: update user which exists
|
||||||
variables:
|
variables:
|
||||||
uid: 1000
|
uid: 1000
|
||||||
@@ -85,7 +86,7 @@
|
|||||||
- {"check": "status_code", "expect": 200}
|
- {"check": "status_code", "expect": 200}
|
||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get user that has been updated
|
name: get user that has been updated
|
||||||
api: api/get_user.yml
|
api: api/get_user.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -96,7 +97,7 @@
|
|||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
- {"check": "content.data.password", "expect": "654321"}
|
- {"check": "content.data.password", "expect": "654321"}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get users
|
name: get users
|
||||||
api: api/get_users.yml
|
api: api/get_users.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
- {"check": "status_code", "expect": 200}
|
- {"check": "status_code", "expect": 200}
|
||||||
- {"check": "content.count", "expect": 1}
|
- {"check": "content.count", "expect": 1}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: delete user that exists
|
name: delete user that exists
|
||||||
api: api/delete_user.yml
|
api: api/delete_user.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -115,7 +116,7 @@
|
|||||||
- {"check": "status_code", "expect": 200}
|
- {"check": "status_code", "expect": 200}
|
||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get users
|
name: get users
|
||||||
api: api/get_users.yml
|
api: api/get_users.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -124,7 +125,7 @@
|
|||||||
- {"check": "status_code", "expect": 200}
|
- {"check": "status_code", "expect": 200}
|
||||||
- {"check": "content.count", "expect": 0}
|
- {"check": "content.count", "expect": 0}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which has been deleted
|
name: create user which has been deleted
|
||||||
variables:
|
variables:
|
||||||
uid: 1000
|
uid: 1000
|
||||||
@@ -136,7 +137,7 @@
|
|||||||
- {"check": "status_code", "expect": 201}
|
- {"check": "status_code", "expect": 201}
|
||||||
- {"check": "content.success", "expect": true}
|
- {"check": "content.success", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get users
|
name: get users
|
||||||
api: api/get_users.yml
|
api: api/get_users.yml
|
||||||
variables:
|
variables:
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
- config:
|
config:
|
||||||
name: "create user testcases."
|
name: "create user testcases."
|
||||||
variables:
|
variables:
|
||||||
device_sn: 'HZfFBh6tU59EdXJ'
|
device_sn: 'HZfFBh6tU59EdXJ'
|
||||||
base_url: ${get_base_url()}
|
base_url: ${get_base_url()}
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: get token
|
name: get token
|
||||||
variables:
|
variables:
|
||||||
user_agent: 'iOS/10.3'
|
user_agent: 'iOS/10.3'
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
||||||
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
|
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
variables:
|
variables:
|
||||||
user_name: "user1"
|
user_name: "user1"
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
- {"check": "status_code", "comparator": "eq", "expect": 201}
|
||||||
- {"check": "content.success", "comparator": "eq", "expect": true}
|
- {"check": "content.success", "comparator": "eq", "expect": true}
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
request:
|
request:
|
||||||
url: /api/users/1000
|
url: /api/users/1000
|
||||||
|
|||||||
+11
-20
@@ -1,18 +1,9 @@
|
|||||||
- config:
|
config:
|
||||||
name: basic test with httpbin
|
name: basic test with httpbin
|
||||||
base_url: https://httpbin.org/
|
base_url: https://httpbin.org/
|
||||||
|
|
||||||
#- test:
|
teststeps:
|
||||||
# TODO: fix compatibility with Python 2.7, UnicodeDecodeError
|
-
|
||||||
# name: index
|
|
||||||
# request:
|
|
||||||
# url: /
|
|
||||||
# method: GET
|
|
||||||
# validate:
|
|
||||||
# - eq: ["status_code", 200]
|
|
||||||
# - contains: [content, "HTTP Request & Response Service"]
|
|
||||||
|
|
||||||
- test:
|
|
||||||
name: headers
|
name: headers
|
||||||
request:
|
request:
|
||||||
url: /headers
|
url: /headers
|
||||||
@@ -21,7 +12,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: [content.headers.Host, "httpbin.org"]
|
- eq: [content.headers.Host, "httpbin.org"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: user-agent
|
name: user-agent
|
||||||
request:
|
request:
|
||||||
url: /user-agent
|
url: /user-agent
|
||||||
@@ -30,7 +21,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- startswith: [content.user-agent, "python-requests"]
|
- startswith: [content.user-agent, "python-requests"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get without params
|
name: get without params
|
||||||
request:
|
request:
|
||||||
url: /get
|
url: /get
|
||||||
@@ -39,7 +30,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: [content.args, {}]
|
- eq: [content.args, {}]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get with params in url
|
name: get with params in url
|
||||||
request:
|
request:
|
||||||
url: /get?a=1&b=2
|
url: /get?a=1&b=2
|
||||||
@@ -48,7 +39,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: [content.args, {'a': '1', 'b': '2'}]
|
- eq: [content.args, {'a': '1', 'b': '2'}]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get with params in params field
|
name: get with params in params field
|
||||||
request:
|
request:
|
||||||
url: /get
|
url: /get
|
||||||
@@ -60,7 +51,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: [content.args, {'a': '1', 'b': '2'}]
|
- eq: [content.args, {'a': '1', 'b': '2'}]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: set cookie
|
name: set cookie
|
||||||
request:
|
request:
|
||||||
url: /cookies/set?name=value
|
url: /cookies/set?name=value
|
||||||
@@ -69,7 +60,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
# - eq: [cookies.name, "value"]
|
# - eq: [cookies.name, "value"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: extract cookie
|
name: extract cookie
|
||||||
request:
|
request:
|
||||||
url: /cookies
|
url: /cookies
|
||||||
@@ -78,7 +69,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
# - eq: [cookies.name, "value"]
|
# - eq: [cookies.name, "value"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: post data
|
name: post data
|
||||||
request:
|
request:
|
||||||
url: /post
|
url: /post
|
||||||
@@ -89,7 +80,7 @@
|
|||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: validate content length
|
name: validate content length
|
||||||
request:
|
request:
|
||||||
url: /spec.json
|
url: /spec.json
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
- config:
|
config:
|
||||||
name: basic test with httpbin
|
name: basic test with httpbin
|
||||||
base_url: ${get_httpbin_server()}
|
base_url: ${get_httpbin_server()}
|
||||||
setup_hooks:
|
setup_hooks:
|
||||||
@@ -6,7 +6,8 @@
|
|||||||
teardown_hooks:
|
teardown_hooks:
|
||||||
- ${hook_print(teardown)}
|
- ${hook_print(teardown)}
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: headers
|
name: headers
|
||||||
request:
|
request:
|
||||||
url: /headers
|
url: /headers
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- contained_by: [content.headers.Host, "${get_httpbin_server()}"]
|
- contained_by: [content.headers.Host, "${get_httpbin_server()}"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: alter response
|
name: alter response
|
||||||
request:
|
request:
|
||||||
url: /headers
|
url: /headers
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
- config:
|
config:
|
||||||
name: load images
|
name: load images
|
||||||
base_url: ${get_httpbin_server()}
|
base_url: ${get_httpbin_server()}
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: get png image
|
name: get png image
|
||||||
request:
|
request:
|
||||||
url: /image/png
|
url: /image/png
|
||||||
@@ -10,7 +11,7 @@
|
|||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get jpeg image
|
name: get jpeg image
|
||||||
request:
|
request:
|
||||||
url: /image/jpeg
|
url: /image/jpeg
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get webp image
|
name: get webp image
|
||||||
request:
|
request:
|
||||||
url: /image/webp
|
url: /image/webp
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: get svg image
|
name: get svg image
|
||||||
request:
|
request:
|
||||||
url: /image/svg
|
url: /image/svg
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
config:
|
|
||||||
name: test upload file with httpbin
|
|
||||||
base_url: ${get_httpbin_server()}
|
|
||||||
|
|
||||||
teststeps:
|
|
||||||
-
|
|
||||||
name: upload file
|
|
||||||
variables:
|
|
||||||
file_path: "data/test.env"
|
|
||||||
m_encoder: ${multipart_encoder(file=$file_path)}
|
|
||||||
request:
|
|
||||||
url: /post
|
|
||||||
method: POST
|
|
||||||
headers:
|
|
||||||
Content-Type: ${multipart_content_type($m_encoder)}
|
|
||||||
data: $m_encoder
|
|
||||||
validate:
|
|
||||||
- eq: ["status_code", 200]
|
|
||||||
- startswith: ["content.files.file", "UserName=test"]
|
|
||||||
|
|
||||||
-
|
|
||||||
name: upload file with keyword
|
|
||||||
request:
|
|
||||||
url: /post
|
|
||||||
method: POST
|
|
||||||
upload:
|
|
||||||
file: "data/test.env"
|
|
||||||
validate:
|
|
||||||
- eq: ["status_code", 200]
|
|
||||||
- startswith: ["content.files.file", "UserName=test"]
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
- config:
|
config:
|
||||||
name: test upload file with httpbin
|
name: test upload file with httpbin
|
||||||
base_url: ${get_httpbin_server()}
|
base_url: ${get_httpbin_server()}
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: upload file
|
name: upload file
|
||||||
variables:
|
variables:
|
||||||
file_path: "data/test.env"
|
file_path: "data/test.env"
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- startswith: ["content.files.file", "UserName=test"]
|
- startswith: ["content.files.file", "UserName=test"]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: upload file with keyword
|
name: upload file with keyword
|
||||||
request:
|
request:
|
||||||
url: /post
|
url: /post
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
- config:
|
config:
|
||||||
name: basic test with httpbin
|
name: basic test with httpbin
|
||||||
base_url: http://httpbin.org/
|
base_url: http://httpbin.org/
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: validate response with json path
|
name: validate response with json path
|
||||||
request:
|
request:
|
||||||
url: /get
|
url: /get
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
- "assert status_code == 200"
|
- "assert status_code == 200"
|
||||||
|
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: validate response with python script
|
name: validate response with python script
|
||||||
request:
|
request:
|
||||||
url: /get
|
url: /get
|
||||||
|
|||||||
@@ -5,14 +5,16 @@ config:
|
|||||||
base_url: "http://127.0.0.1:5000"
|
base_url: "http://127.0.0.1:5000"
|
||||||
|
|
||||||
testcases:
|
testcases:
|
||||||
create user 1000 and check result.:
|
-
|
||||||
testcase: testcases/create_user.yml
|
name: create user 1000 and check result.
|
||||||
weight: 2
|
testcase: testcases/create_user.yml
|
||||||
variables:
|
weight: 2
|
||||||
uid: 1000
|
variables:
|
||||||
|
uid: 1000
|
||||||
|
|
||||||
create user 1001 and check result.:
|
-
|
||||||
testcase: testcases/create_user.yml
|
name: create user 1001 and check result.
|
||||||
weight: 3
|
testcase: testcases/create_user.yml
|
||||||
variables:
|
weight: 3
|
||||||
uid: 1001
|
variables:
|
||||||
|
uid: 1001
|
||||||
|
|||||||
+7
-28
@@ -14,12 +14,6 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.testcase_cli_path = "tests/data/demo_testcase_cli.yml"
|
self.testcase_cli_path = "tests/data/demo_testcase_cli.yml"
|
||||||
self.testcase_file_path_list = [
|
|
||||||
os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml'),
|
|
||||||
os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
|
|
||||||
]
|
|
||||||
testcases = [{
|
testcases = [{
|
||||||
'config': {
|
'config': {
|
||||||
'name': 'testcase description',
|
'name': 'testcase description',
|
||||||
@@ -223,17 +217,12 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertIn("records", summary["details"][0])
|
self.assertIn("records", summary["details"][0])
|
||||||
|
|
||||||
def test_run_yaml_upload(self):
|
def test_run_yaml_upload(self):
|
||||||
upload_cases_list = [
|
summary = self.runner.run("tests/httpbin/upload.yml")
|
||||||
"tests/httpbin/upload.yml",
|
self.assertTrue(summary["success"])
|
||||||
"tests/httpbin/upload.v2.yml"
|
self.assertEqual(summary["stat"]["testcases"]["total"], 1)
|
||||||
]
|
self.assertEqual(summary["stat"]["teststeps"]["total"], 2)
|
||||||
for upload_case in upload_cases_list:
|
self.assertIn("details", summary)
|
||||||
summary = self.runner.run(upload_case)
|
self.assertIn("records", summary["details"][0])
|
||||||
self.assertTrue(summary["success"])
|
|
||||||
self.assertEqual(summary["stat"]["testcases"]["total"], 1)
|
|
||||||
self.assertEqual(summary["stat"]["teststeps"]["total"], 2)
|
|
||||||
self.assertIn("details", summary)
|
|
||||||
self.assertIn("records", summary["details"][0])
|
|
||||||
|
|
||||||
def test_run_post_data(self):
|
def test_run_post_data(self):
|
||||||
testcases = [
|
testcases = [
|
||||||
@@ -470,14 +459,6 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertEqual(summary["details"][1]["stat"]["total"], 1)
|
self.assertEqual(summary["details"][1]["stat"]["total"], 1)
|
||||||
self.assertEqual(summary["details"][2]["stat"]["total"], 1)
|
self.assertEqual(summary["details"][2]["stat"]["total"], 1)
|
||||||
|
|
||||||
def test_run_testcase_hardcode(self):
|
|
||||||
for testcase_file_path in self.testcase_file_path_list:
|
|
||||||
summary = self.runner.run(testcase_file_path)
|
|
||||||
self.assertTrue(summary["success"])
|
|
||||||
self.assertEqual(summary["stat"]["testcases"]["total"], 1)
|
|
||||||
self.assertEqual(summary["stat"]["teststeps"]["total"], 3)
|
|
||||||
self.assertEqual(summary["stat"]["teststeps"]["successes"], 3)
|
|
||||||
|
|
||||||
def test_run_testcase_template_variables(self):
|
def test_run_testcase_template_variables(self):
|
||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'tests/data/demo_testcase_variables.yml')
|
os.getcwd(), 'tests/data/demo_testcase_variables.yml')
|
||||||
@@ -693,9 +674,7 @@ class TestApi(ApiServerUnittest):
|
|||||||
def test_testcase_complex_run_suite(self):
|
def test_testcase_complex_run_suite(self):
|
||||||
for testcase_path in [
|
for testcase_path in [
|
||||||
"tests/testcases/create_user.yml",
|
"tests/testcases/create_user.yml",
|
||||||
"tests/testcases/create_user.v2.yml",
|
"tests/testcases/create_user.json"
|
||||||
"tests/testcases/create_user.json",
|
|
||||||
"tests/testcases/create_user.v2.json"
|
|
||||||
]:
|
]:
|
||||||
tests_mapping = loader.load_cases(testcase_path)
|
tests_mapping = loader.load_cases(testcase_path)
|
||||||
testcases = parser.parse_tests(tests_mapping)
|
testcases = parser.parse_tests(tests_mapping)
|
||||||
|
|||||||
@@ -25,23 +25,6 @@ class TestRunner(ApiServerUnittest):
|
|||||||
headers = self.get_authenticated_headers()
|
headers = self.get_authenticated_headers()
|
||||||
return self.api_client.get(url, headers=headers)
|
return self.api_client.get(url, headers=headers)
|
||||||
|
|
||||||
def test_run_single_testcase(self):
|
|
||||||
testcase_file_path_list = [
|
|
||||||
os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.yml'),
|
|
||||||
os.path.join(
|
|
||||||
os.getcwd(), 'tests/data/demo_testcase_hardcode.json')
|
|
||||||
]
|
|
||||||
|
|
||||||
for testcase_file_path in testcase_file_path_list:
|
|
||||||
tests_mapping = loader.load_cases(testcase_file_path)
|
|
||||||
parsed_testcases = parser.parse_tests(tests_mapping)
|
|
||||||
parsed_testcase = parsed_testcases[0]
|
|
||||||
test_runner = runner.Runner(parsed_testcase["config"])
|
|
||||||
test_runner.run_test(parsed_testcase["teststeps"][0])
|
|
||||||
test_runner.run_test(parsed_testcase["teststeps"][1])
|
|
||||||
test_runner.run_test(parsed_testcase["teststeps"][2])
|
|
||||||
|
|
||||||
def test_run_testcase_with_hooks(self):
|
def test_run_testcase_with_hooks(self):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,30 @@
|
|||||||
[
|
{
|
||||||
{
|
"config": {
|
||||||
"config": {
|
"id": "create_user",
|
||||||
"id": "create_user",
|
"variables": {
|
||||||
"variables": {
|
"device_sn": "TESTCASE_CREATE_XXX",
|
||||||
"device_sn": "TESTCASE_CREATE_XXX",
|
"uid": 9001
|
||||||
"uid": 9001
|
},
|
||||||
},
|
"output": [
|
||||||
"output": [
|
"session_token"
|
||||||
"session_token"
|
],
|
||||||
],
|
"base_url": "http://127.0.0.1:5000",
|
||||||
"base_url": "http://127.0.0.1:5000",
|
"name": "create user and check result."
|
||||||
"name": "create user and check result."
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
"teststeps": [
|
||||||
"test": {
|
{
|
||||||
"testcase": "testcases/setup.yml",
|
"testcase": "testcases/setup.yml",
|
||||||
"extract": [
|
"extract": [
|
||||||
"session_token"
|
"session_token"
|
||||||
],
|
],
|
||||||
"name": "setup and reset all (override) for $device_sn."
|
"name": "setup and reset all (override) for $device_sn."
|
||||||
}
|
},
|
||||||
},
|
{
|
||||||
{
|
|
||||||
"test": {
|
|
||||||
"testcase": "testcases/deps/check_and_create.yml",
|
"testcase": "testcases/deps/check_and_create.yml",
|
||||||
"variables": {
|
"variables": {
|
||||||
"token": "$session_token"
|
"token": "$session_token"
|
||||||
},
|
},
|
||||||
"name": "create user and check result."
|
"name": "create user and check result."
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"config": {
|
|
||||||
"id": "create_user",
|
|
||||||
"variables": {
|
|
||||||
"device_sn": "TESTCASE_CREATE_XXX",
|
|
||||||
"uid": 9001
|
|
||||||
},
|
|
||||||
"output": [
|
|
||||||
"session_token"
|
|
||||||
],
|
|
||||||
"base_url": "http://127.0.0.1:5000",
|
|
||||||
"name": "create user and check result."
|
|
||||||
},
|
|
||||||
"teststeps": [
|
|
||||||
{
|
|
||||||
"testcase": "testcases/setup.yml",
|
|
||||||
"extract": [
|
|
||||||
"session_token"
|
|
||||||
],
|
|
||||||
"name": "setup and reset all (override) for $device_sn."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"testcase": "testcases/deps/check_and_create.yml",
|
|
||||||
"variables": {
|
|
||||||
"token": "$session_token"
|
|
||||||
},
|
|
||||||
"name": "create user and check result."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
config:
|
|
||||||
name: "create user and check result."
|
|
||||||
id: create_user
|
|
||||||
base_url: "http://127.0.0.1:5000"
|
|
||||||
variables:
|
|
||||||
uid: 9001
|
|
||||||
device_sn: "TESTCASE_CREATE_XXX"
|
|
||||||
export:
|
|
||||||
- session_token
|
|
||||||
|
|
||||||
teststeps:
|
|
||||||
-
|
|
||||||
name: setup and reset all (override) for $device_sn.
|
|
||||||
testcase: testcases/setup.yml
|
|
||||||
extract:
|
|
||||||
- session_token
|
|
||||||
-
|
|
||||||
name: create user and check result.
|
|
||||||
variables:
|
|
||||||
token: $session_token
|
|
||||||
testcase: testcases/deps/check_and_create.yml
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
|
config:
|
||||||
- config:
|
|
||||||
name: "create user and check result."
|
name: "create user and check result."
|
||||||
id: create_user
|
id: create_user
|
||||||
base_url: "http://127.0.0.1:5000"
|
base_url: "http://127.0.0.1:5000"
|
||||||
@@ -9,13 +8,13 @@
|
|||||||
export:
|
export:
|
||||||
- session_token
|
- session_token
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: setup and reset all (override) for $device_sn.
|
name: setup and reset all (override) for $device_sn.
|
||||||
testcase: testcases/setup.yml
|
testcase: testcases/setup.yml
|
||||||
extract:
|
extract:
|
||||||
- session_token
|
- session_token
|
||||||
|
-
|
||||||
- test:
|
|
||||||
name: create user and check result.
|
name: create user and check result.
|
||||||
variables:
|
variables:
|
||||||
token: $session_token
|
token: $session_token
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
- config:
|
config:
|
||||||
name: "create user and check result."
|
name: "create user and check result."
|
||||||
id: create_and_check
|
id: create_and_check
|
||||||
base_url: "http://127.0.0.1:5000"
|
base_url: "http://127.0.0.1:5000"
|
||||||
@@ -6,7 +6,8 @@
|
|||||||
uid: 9001
|
uid: 9001
|
||||||
device_sn: "TESTCASE_CREATE_XXX"
|
device_sn: "TESTCASE_CREATE_XXX"
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: make sure user $uid does not exist
|
name: make sure user $uid does not exist
|
||||||
api: api/get_user.yml
|
api: api/get_user.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
- eq: ["status_code", 404]
|
- eq: ["status_code", 404]
|
||||||
- eq: ["content.success", false]
|
- eq: ["content.success", false]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: create user $uid for $device_sn
|
name: create user $uid for $device_sn
|
||||||
api: api/create_user.yml
|
api: api/create_user.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
- eq: ["status_code", 201]
|
- eq: ["status_code", 201]
|
||||||
- eq: ["content.success", true]
|
- eq: ["content.success", true]
|
||||||
|
|
||||||
- test:
|
-
|
||||||
name: check if user $uid exists
|
name: check if user $uid exists
|
||||||
api: api/get_user.yml
|
api: api/get_user.yml
|
||||||
variables:
|
variables:
|
||||||
|
|||||||
+32
-48
@@ -1,59 +1,43 @@
|
|||||||
[
|
{
|
||||||
{
|
"config": {
|
||||||
"config": {
|
"name": "setup and reset all.",
|
||||||
"name": "setup and reset all.",
|
"base_url": "http://127.0.0.1:5000",
|
||||||
"output": [
|
"variables": {
|
||||||
"session_token"
|
"device_sn": "TESTCASE_SETUP_XXX",
|
||||||
],
|
"app_version": "2.8.6",
|
||||||
"verify": false,
|
"os_platform": "ios",
|
||||||
"variables": {
|
"user_agent": "iOS/10.3"
|
||||||
"device_sn": "TESTCASE_SETUP_XXX",
|
},
|
||||||
"app_version": "2.8.6",
|
"id": "setup_and_reset",
|
||||||
"os_platform": "ios",
|
"verify": false,
|
||||||
"user_agent": "iOS/10.3"
|
"output": [
|
||||||
},
|
"session_token"
|
||||||
"base_url": "http://127.0.0.1:5000",
|
]
|
||||||
"id": "setup_and_reset"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
"teststeps": [
|
||||||
"test": {
|
{
|
||||||
"validate": [
|
"name": "get token (setup)",
|
||||||
{
|
|
||||||
"eq": [
|
|
||||||
"status_code",
|
|
||||||
200
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"len_eq": [
|
|
||||||
"content.token",
|
|
||||||
16
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"api": "api/get_token.yml",
|
"api": "api/get_token.yml",
|
||||||
"extract": [
|
|
||||||
{
|
|
||||||
"session_token": "content.token"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"variables": {
|
"variables": {
|
||||||
"device_sn": "$device_sn",
|
"device_sn": "$device_sn",
|
||||||
"app_version": "2.8.6",
|
"app_version": "2.8.6",
|
||||||
"os_platform": "ios",
|
"os_platform": "ios",
|
||||||
"user_agent": "iOS/10.3"
|
"user_agent": "iOS/10.3"
|
||||||
},
|
},
|
||||||
"name": "get token (setup)"
|
"extract": [
|
||||||
}
|
{"session_token": "content.token"}
|
||||||
},
|
],
|
||||||
{
|
"validate": [
|
||||||
"test": {
|
{"eq": ["status_code", 200]},
|
||||||
|
{"len_eq": ["content.token", 16]}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "reset all users",
|
||||||
|
"api": "api/reset_all.yml",
|
||||||
"variables": {
|
"variables": {
|
||||||
"token": "$session_token"
|
"token": "$session_token"
|
||||||
},
|
}
|
||||||
"api": "api/reset_all.yml",
|
|
||||||
"name": "reset all users"
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
{
|
|
||||||
"config": {
|
|
||||||
"name": "setup and reset all.",
|
|
||||||
"base_url": "http://127.0.0.1:5000",
|
|
||||||
"variables": {
|
|
||||||
"device_sn": "TESTCASE_SETUP_XXX",
|
|
||||||
"app_version": "2.8.6",
|
|
||||||
"os_platform": "ios",
|
|
||||||
"user_agent": "iOS/10.3"
|
|
||||||
},
|
|
||||||
"id": "setup_and_reset",
|
|
||||||
"verify": false,
|
|
||||||
"output": [
|
|
||||||
"session_token"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"teststeps": [
|
|
||||||
{
|
|
||||||
"name": "get token (setup)",
|
|
||||||
"api": "api/get_token.yml",
|
|
||||||
"variables": {
|
|
||||||
"device_sn": "$device_sn",
|
|
||||||
"app_version": "2.8.6",
|
|
||||||
"os_platform": "ios",
|
|
||||||
"user_agent": "iOS/10.3"
|
|
||||||
},
|
|
||||||
"extract": [
|
|
||||||
{"session_token": "content.token"}
|
|
||||||
],
|
|
||||||
"validate": [
|
|
||||||
{"eq": ["status_code", 200]},
|
|
||||||
{"len_eq": ["content.token", 16]}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "reset all users",
|
|
||||||
"api": "api/reset_all.yml",
|
|
||||||
"variables": {
|
|
||||||
"token": "$session_token"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
config:
|
|
||||||
name: "setup and reset all."
|
|
||||||
id: setup_and_reset
|
|
||||||
variables:
|
|
||||||
user_agent: 'iOS/10.3'
|
|
||||||
device_sn: "TESTCASE_SETUP_XXX"
|
|
||||||
os_platform: 'ios'
|
|
||||||
app_version: '2.8.6'
|
|
||||||
base_url: "http://127.0.0.1:5000"
|
|
||||||
verify: False
|
|
||||||
export:
|
|
||||||
- session_token
|
|
||||||
|
|
||||||
teststeps:
|
|
||||||
-
|
|
||||||
name: get token (setup)
|
|
||||||
api: api/get_token.yml
|
|
||||||
variables:
|
|
||||||
user_agent: 'iOS/10.3'
|
|
||||||
device_sn: $device_sn
|
|
||||||
os_platform: 'ios'
|
|
||||||
app_version: '2.8.6'
|
|
||||||
extract:
|
|
||||||
- session_token: content.token
|
|
||||||
validate:
|
|
||||||
- eq: ["status_code", 200]
|
|
||||||
- len_eq: ["content.token", 16]
|
|
||||||
-
|
|
||||||
name: reset all users
|
|
||||||
api: api/reset_all.yml
|
|
||||||
variables:
|
|
||||||
token: $session_token
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
- config:
|
config:
|
||||||
name: "setup and reset all."
|
name: "setup and reset all."
|
||||||
id: setup_and_reset
|
id: setup_and_reset
|
||||||
variables:
|
variables:
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
export:
|
export:
|
||||||
- session_token
|
- session_token
|
||||||
|
|
||||||
- test:
|
teststeps:
|
||||||
|
-
|
||||||
name: get token (setup)
|
name: get token (setup)
|
||||||
api: api/get_token.yml
|
api: api/get_token.yml
|
||||||
variables:
|
variables:
|
||||||
@@ -24,8 +25,7 @@
|
|||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- len_eq: ["content.token", 16]
|
- len_eq: ["content.token", 16]
|
||||||
|
-
|
||||||
- test:
|
|
||||||
name: reset all users
|
name: reset all users
|
||||||
api: api/reset_all.yml
|
api: api/reset_all.yml
|
||||||
variables:
|
variables:
|
||||||
|
|||||||
@@ -1,22 +1,4 @@
|
|||||||
{
|
{
|
||||||
"testcases": {
|
|
||||||
"create user 1001 and check result.": {
|
|
||||||
"testcase": "testcases/create_user.yml",
|
|
||||||
"variables": {
|
|
||||||
"var_d": "$var_c",
|
|
||||||
"var_c": "${gen_random_string(5)}",
|
|
||||||
"uid": 1001
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"create user 1000 and check result.": {
|
|
||||||
"testcase": "testcases/create_user.yml",
|
|
||||||
"variables": {
|
|
||||||
"var_d": "$var_c",
|
|
||||||
"var_c": "${gen_random_string(5)}",
|
|
||||||
"uid": 1000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"config": {
|
"config": {
|
||||||
"variables": {
|
"variables": {
|
||||||
"device_sn": "${gen_random_string(15)}",
|
"device_sn": "${gen_random_string(15)}",
|
||||||
@@ -25,5 +7,25 @@
|
|||||||
},
|
},
|
||||||
"name": "create users with uid",
|
"name": "create users with uid",
|
||||||
"base_url": "http://127.0.0.1:5000"
|
"base_url": "http://127.0.0.1:5000"
|
||||||
}
|
},
|
||||||
|
"testcases": [
|
||||||
|
{
|
||||||
|
"name": "create user 1000 and check result.",
|
||||||
|
"testcase": "testcases/create_user.yml",
|
||||||
|
"variables": {
|
||||||
|
"var_d": "$var_c",
|
||||||
|
"var_c": "${gen_random_string(5)}",
|
||||||
|
"uid": 1000
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "create user 1001 and check result.",
|
||||||
|
"testcase": "testcases/create_user.yml",
|
||||||
|
"variables": {
|
||||||
|
"var_d": "$var_c",
|
||||||
|
"var_c": "${gen_random_string(5)}",
|
||||||
|
"uid": 1001
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"config": {
|
|
||||||
"variables": {
|
|
||||||
"device_sn": "${gen_random_string(15)}",
|
|
||||||
"var_b": "$var_a",
|
|
||||||
"var_a": "${gen_random_string(5)}"
|
|
||||||
},
|
|
||||||
"name": "create users with uid",
|
|
||||||
"base_url": "http://127.0.0.1:5000"
|
|
||||||
},
|
|
||||||
"testcases": [
|
|
||||||
{
|
|
||||||
"name": "create user 1000 and check result.",
|
|
||||||
"testcase": "testcases/create_user.v2.yml",
|
|
||||||
"variables": {
|
|
||||||
"var_d": "$var_c",
|
|
||||||
"var_c": "${gen_random_string(5)}",
|
|
||||||
"uid": 1000
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "create user 1001 and check result.",
|
|
||||||
"testcase": "testcases/create_user.v2.yml",
|
|
||||||
"variables": {
|
|
||||||
"var_d": "$var_c",
|
|
||||||
"var_c": "${gen_random_string(5)}",
|
|
||||||
"uid": 1001
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
config:
|
|
||||||
name: create users with uid
|
|
||||||
variables:
|
|
||||||
device_sn: ${gen_random_string(15)}
|
|
||||||
var_a: ${gen_random_string(5)}
|
|
||||||
var_b: $var_a
|
|
||||||
base_url: "http://127.0.0.1:5000"
|
|
||||||
|
|
||||||
testcases:
|
|
||||||
-
|
|
||||||
name: create user 1000 and check result.
|
|
||||||
testcase: testcases/create_user.v2.yml
|
|
||||||
variables:
|
|
||||||
uid: 1000
|
|
||||||
var_c: ${gen_random_string(5)}
|
|
||||||
var_d: $var_c
|
|
||||||
|
|
||||||
-
|
|
||||||
name: create user 1001 and check result.
|
|
||||||
testcase: testcases/create_user.v2.yml
|
|
||||||
variables:
|
|
||||||
uid: 1001
|
|
||||||
var_c: ${gen_random_string(5)}
|
|
||||||
var_d: $var_c
|
|
||||||
@@ -7,16 +7,18 @@ config:
|
|||||||
base_url: "http://127.0.0.1:5000"
|
base_url: "http://127.0.0.1:5000"
|
||||||
|
|
||||||
testcases:
|
testcases:
|
||||||
create user 1000 and check result.:
|
-
|
||||||
testcase: testcases/create_user.yml
|
name: create user 1000 and check result.
|
||||||
variables:
|
testcase: testcases/create_user.yml
|
||||||
uid: 1000
|
variables:
|
||||||
var_c: ${gen_random_string(5)}
|
uid: 1000
|
||||||
var_d: $var_c
|
var_c: ${gen_random_string(5)}
|
||||||
|
var_d: $var_c
|
||||||
|
|
||||||
create user 1001 and check result.:
|
-
|
||||||
testcase: testcases/create_user.yml
|
name: create user 1001 and check result.
|
||||||
variables:
|
testcase: testcases/create_user.yml
|
||||||
uid: 1001
|
variables:
|
||||||
var_c: ${gen_random_string(5)}
|
uid: 1001
|
||||||
var_d: $var_c
|
var_c: ${gen_random_string(5)}
|
||||||
|
var_d: $var_c
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ config:
|
|||||||
base_url: "http://127.0.0.1:5000"
|
base_url: "http://127.0.0.1:5000"
|
||||||
|
|
||||||
testcases:
|
testcases:
|
||||||
create user $uid and check result for $device_sn.:
|
-
|
||||||
testcase: testcases/create_user.yml
|
name: create user $uid and check result for $device_sn.
|
||||||
variables:
|
testcase: testcases/create_user.yml
|
||||||
uid: 1000
|
variables:
|
||||||
device_sn: TESTSUITE_XXX
|
uid: 1000
|
||||||
parameters:
|
device_sn: TESTSUITE_XXX
|
||||||
uid: [101, 102, 103]
|
parameters:
|
||||||
device_sn: [TESTSUITE_X1, TESTSUITE_X2]
|
uid: [101, 102, 103]
|
||||||
|
device_sn: [TESTSUITE_X1, TESTSUITE_X2]
|
||||||
|
|||||||
Reference in New Issue
Block a user