mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
add unittest: variables in testcase teststep should override api's
This commit is contained in:
@@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
- api:
|
- api:
|
||||||
def: create_user($uid, $user_name, $user_password, $token)
|
def: create_user($uid, $user_name, $user_password, $token)
|
||||||
|
variables:
|
||||||
|
- user_name: user0
|
||||||
|
- user_password: "000000"
|
||||||
|
- uid: 2000
|
||||||
request:
|
request:
|
||||||
url: /api/users/$uid
|
url: /api/users/$uid
|
||||||
method: POST
|
method: POST
|
||||||
|
|||||||
@@ -465,6 +465,17 @@ class TestSuiteLoader(unittest.TestCase):
|
|||||||
testcases_list = loader.load_tests(path)
|
testcases_list = loader.load_tests(path)
|
||||||
self.assertIn("variables", testcases_list[0]["config"])
|
self.assertIn("variables", testcases_list[0]["config"])
|
||||||
self.assertIn("request", testcases_list[0]["config"])
|
self.assertIn("request", testcases_list[0]["config"])
|
||||||
|
|
||||||
|
# variables in testcase teststep should override api's
|
||||||
|
self.assertEqual(
|
||||||
|
testcases_list[0]["teststeps"][3]["variables"][0]["user_name"],
|
||||||
|
"user1"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
testcases_list[0]["teststeps"][3]["variables"][2]["uid"],
|
||||||
|
2000
|
||||||
|
)
|
||||||
|
|
||||||
self.assertIn("request", testcases_list[0]["teststeps"][0])
|
self.assertIn("request", testcases_list[0]["teststeps"][0])
|
||||||
self.assertIn("url", testcases_list[0]["teststeps"][0]["request"])
|
self.assertIn("url", testcases_list[0]["teststeps"][0]["request"])
|
||||||
self.assertIn("validate", testcases_list[0]["teststeps"][0])
|
self.assertIn("validate", testcases_list[0]["teststeps"][0])
|
||||||
|
|||||||
Reference in New Issue
Block a user