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