mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-08 00:47:36 +08:00
change testcase data structure, in order to distinguish config and test
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
-
|
- test:
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
requires:
|
requires:
|
||||||
- random
|
- random
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
success: true
|
success: true
|
||||||
msg: user created successfully.
|
msg: user created successfully.
|
||||||
|
|
||||||
-
|
- test:
|
||||||
name: create user which does not exist
|
name: create user which does not exist
|
||||||
requires:
|
requires:
|
||||||
- random
|
- random
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"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",
|
||||||
@@ -24,8 +25,10 @@
|
|||||||
"msg": "user created successfully."
|
"msg": "user created successfully."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"test": {
|
||||||
"name": "create user which existed",
|
"name": "create user which existed",
|
||||||
"request": {
|
"request": {
|
||||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||||
@@ -51,4 +54,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
-
|
- 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
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
success: true
|
success: true
|
||||||
msg: user created successfully.
|
msg: user created successfully.
|
||||||
|
|
||||||
-
|
- test:
|
||||||
name: create user which existed
|
name: create user which existed
|
||||||
request:
|
request:
|
||||||
url: http://127.0.0.1:5000/api/users/1000
|
url: http://127.0.0.1:5000/api/users/1000
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
"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",
|
||||||
@@ -23,8 +24,10 @@
|
|||||||
"msg": "user created successfully."
|
"msg": "user created successfully."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"test": {
|
||||||
"name": "create user which existed",
|
"name": "create user which existed",
|
||||||
"request": {
|
"request": {
|
||||||
"url": "http://127.0.0.1:5000/api/users/1000",
|
"url": "http://127.0.0.1:5000/api/users/1000",
|
||||||
@@ -48,4 +51,5 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
-
|
- 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
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
success: true
|
success: true
|
||||||
msg: user created successfully.
|
msg: user created successfully.
|
||||||
|
|
||||||
-
|
- test:
|
||||||
name: create user which existed
|
name: create user which existed
|
||||||
request:
|
request:
|
||||||
url: http://127.0.0.1:5000/api/users/1000
|
url: http://127.0.0.1:5000/api/users/1000
|
||||||
|
|||||||
+10
-2
@@ -14,10 +14,18 @@ class TestRunner(ApiServerUnittest):
|
|||||||
url = "http://127.0.0.1:5000/api/users"
|
url = "http://127.0.0.1:5000/api/users"
|
||||||
return requests.delete(url)
|
return requests.delete(url)
|
||||||
|
|
||||||
def test_run_single_testcase_success(self):
|
def test_run_single_testcase_yaml_success(self):
|
||||||
|
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||||
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
|
testcase = testcases[0]["test"]
|
||||||
|
success, _ = self.test_runner.run_test(testcase)
|
||||||
|
self.assertTrue(success)
|
||||||
|
|
||||||
|
def test_run_single_testcase_json_success(self):
|
||||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||||
testcases = utils.load_testcases(testcase_file_path)
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
success, _ = self.test_runner.run_test(testcases[0])
|
testcase = testcases[0]["test"]
|
||||||
|
success, _ = self.test_runner.run_test(testcase)
|
||||||
self.assertTrue(success)
|
self.assertTrue(success)
|
||||||
|
|
||||||
def test_run_single_testcase_fail(self):
|
def test_run_single_testcase_fail(self):
|
||||||
|
|||||||
@@ -20,14 +20,16 @@ class TestRunnerV2(ApiServerUnittest):
|
|||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.yml')
|
os.getcwd(), 'test/data/simple_demo_auth_hardcode.yml')
|
||||||
testcases = utils.load_testcases(testcase_file_path)
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
success, _ = self.test_runner.run_test(testcases[0])
|
testcase = testcases[0]["test"]
|
||||||
|
success, _ = self.test_runner.run_test(testcase)
|
||||||
self.assertTrue(success)
|
self.assertTrue(success)
|
||||||
|
|
||||||
def test_run_single_testcase_json(self):
|
def test_run_single_testcase_json(self):
|
||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.json')
|
os.getcwd(), 'test/data/simple_demo_auth_hardcode.json')
|
||||||
testcases = utils.load_testcases(testcase_file_path)
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
success, _ = self.test_runner.run_test(testcases[0])
|
testcase = testcases[0]["test"]
|
||||||
|
success, _ = self.test_runner.run_test(testcase)
|
||||||
self.assertTrue(success)
|
self.assertTrue(success)
|
||||||
|
|
||||||
def test_run_testcase_auth_suite_yaml(self):
|
def test_run_testcase_auth_suite_yaml(self):
|
||||||
@@ -50,7 +52,7 @@ class TestRunnerV2(ApiServerUnittest):
|
|||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'test/data/demo_template_separate.yml')
|
os.getcwd(), 'test/data/demo_template_separate.yml')
|
||||||
testcases = utils.load_testcases(testcase_file_path)
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
success, _ = self.test_runner.run_test(testcases[0])
|
success, _ = self.test_runner.run_test(testcases[0]["test"])
|
||||||
self.assertTrue(success)
|
self.assertTrue(success)
|
||||||
success, _ = self.test_runner.run_test(testcases[1])
|
success, _ = self.test_runner.run_test(testcases[1]["test"])
|
||||||
self.assertFalse(success)
|
self.assertFalse(success)
|
||||||
|
|||||||
+12
-10
@@ -17,22 +17,24 @@ class TestUtils(ApiServerUnittest):
|
|||||||
os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||||
testcases = utils.load_testcases(testcase_file_path)
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
self.assertEqual(len(testcases), 2)
|
self.assertEqual(len(testcases), 2)
|
||||||
self.assertIn('name', testcases[0])
|
testcase = testcases[0]["test"]
|
||||||
self.assertIn('request', testcases[0])
|
self.assertIn('name', testcase)
|
||||||
self.assertIn('response', testcases[0])
|
self.assertIn('request', testcase)
|
||||||
self.assertIn('url', testcases[0]['request'])
|
self.assertIn('response', testcase)
|
||||||
self.assertIn('method', testcases[0]['request'])
|
self.assertIn('url', testcase['request'])
|
||||||
|
self.assertIn('method', testcase['request'])
|
||||||
|
|
||||||
def test_load_yaml_testcases(self):
|
def test_load_yaml_testcases(self):
|
||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||||
testcases = utils.load_testcases(testcase_file_path)
|
testcases = utils.load_testcases(testcase_file_path)
|
||||||
self.assertEqual(len(testcases), 2)
|
self.assertEqual(len(testcases), 2)
|
||||||
self.assertIn('name', testcases[0])
|
testcase = testcases[0]["test"]
|
||||||
self.assertIn('request', testcases[0])
|
self.assertIn('name', testcase)
|
||||||
self.assertIn('response', testcases[0])
|
self.assertIn('request', testcase)
|
||||||
self.assertIn('url', testcases[0]['request'])
|
self.assertIn('response', testcase)
|
||||||
self.assertIn('method', testcases[0]['request'])
|
self.assertIn('url', testcase['request'])
|
||||||
|
self.assertIn('method', testcase['request'])
|
||||||
|
|
||||||
def test_parse_response_object_json(self):
|
def test_parse_response_object_json(self):
|
||||||
url = "http://127.0.0.1:5000/api/users"
|
url = "http://127.0.0.1:5000/api/users"
|
||||||
|
|||||||
Reference in New Issue
Block a user