mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:29:45 +08:00
runner: replace run_testsets method
This commit is contained in:
@@ -151,7 +151,7 @@ class Runner(object):
|
||||
(dict) variables_mapping:
|
||||
passed in variables mapping, it will override variable_binds in config block
|
||||
|
||||
@return (dict) test result of testcases
|
||||
@return (dict) test result of testset
|
||||
{
|
||||
"success": True,
|
||||
"output": {} # variables mapping
|
||||
@@ -179,24 +179,33 @@ class Runner(object):
|
||||
"output": self.generate_output(output_variables_list)
|
||||
}
|
||||
|
||||
def run_testsets(self, testsets):
|
||||
""" run testsets, including one or several testsets.
|
||||
@param testsets
|
||||
[
|
||||
testset1,
|
||||
testset2,
|
||||
]
|
||||
@return (bool) test result of testsets
|
||||
def run(self, path, mapping=None):
|
||||
""" run specified testset path or folder path.
|
||||
@param
|
||||
path: path could be in several type
|
||||
- absolute/relative file path
|
||||
- absolute/relative folder path
|
||||
- list/set container with file(s) and/or folder(s)
|
||||
(dict) mapping:
|
||||
passed in variables mapping, it will override variable_binds in config block
|
||||
"""
|
||||
success = True
|
||||
mapping = mapping or {}
|
||||
output = {}
|
||||
testsets = testcase.load_testcases_by_path(path)
|
||||
for testset in testsets:
|
||||
try:
|
||||
result = self.run_testset(testset)
|
||||
result = self.run_testset(testset, mapping)
|
||||
assert result["success"]
|
||||
except AssertionError:
|
||||
success = False
|
||||
finally:
|
||||
output.update(result["output"])
|
||||
|
||||
return success
|
||||
return {
|
||||
"success": success,
|
||||
"output": output
|
||||
}
|
||||
|
||||
def generate_output(self, output_variables_list):
|
||||
""" generate and print output
|
||||
|
||||
@@ -73,9 +73,8 @@ class TestRunner(ApiServerUnittest):
|
||||
|
||||
def test_run_testsets_hardcode(self):
|
||||
for testcase_file_path in self.testcase_file_path_list:
|
||||
testsets = testcase.load_testcases_by_path(testcase_file_path)
|
||||
result = self.test_runner.run_testsets(testsets)
|
||||
self.assertTrue(result)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testset_template_variables(self):
|
||||
testcase_file_path = os.path.join(
|
||||
@@ -94,23 +93,20 @@ class TestRunner(ApiServerUnittest):
|
||||
def test_run_testsets_template_import_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_template_import_functions.yml')
|
||||
testsets = testcase.load_testcases_by_path(testcase_file_path)
|
||||
result = self.test_runner.run_testsets(testsets)
|
||||
self.assertTrue(result)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testsets_template_lambda_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_template_lambda_functions.yml')
|
||||
testsets = testcase.load_testcases_by_path(testcase_file_path)
|
||||
result = self.test_runner.run_testsets(testsets)
|
||||
self.assertTrue(result)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testset_layered(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'tests/data/demo_testset_layer.yml')
|
||||
testsets = testcase.load_testcases_by_path(testcase_file_path)
|
||||
result = self.test_runner.run_testsets(testsets)
|
||||
self.assertTrue(result)
|
||||
result = self.test_runner.run(testcase_file_path)
|
||||
self.assertTrue(result["success"])
|
||||
|
||||
def test_run_testset_output(self):
|
||||
testcase_file_path = os.path.join(
|
||||
|
||||
Reference in New Issue
Block a user