rename teststeps to tests

This commit is contained in:
debugtalk
2018-11-23 17:56:53 +08:00
parent 8f4500566d
commit 18875bc5f1
12 changed files with 271 additions and 271 deletions

View File

@@ -38,12 +38,12 @@ class HttpRunner(object):
unittest.TestSuite()
"""
def _add_teststep(test_runner, teststep_dict):
""" add teststep to testcase.
def _add_test(test_runner, test_dict):
""" add test to testcase.
"""
def test(self):
try:
test_runner.run_test(teststep_dict)
test_runner.run_test(test_dict)
except exceptions.MyBaseFailure as ex:
self.fail(str(ex))
finally:
@@ -53,7 +53,7 @@ class HttpRunner(object):
test_runner.http_client_session.init_meta_data()
# TODO: refactor
test.__doc__ = teststep_dict.get("name") or teststep_dict.get("config", {}).get("name")
test.__doc__ = test_dict.get("name") or test_dict.get("config", {}).get("name")
return test
test_suite = unittest.TestSuite()
@@ -64,18 +64,18 @@ class HttpRunner(object):
test_runner = runner.Runner(config, functions, self.http_client_session)
TestSequense = type('TestSequense', (unittest.TestCase,), {})
teststeps = testcase.get("teststeps", [])
for index, teststep_dict in enumerate(teststeps):
for times_index in range(int(teststep_dict.get("times", 1))):
tests = testcase.get("tests", [])
for index, test_dict in enumerate(tests):
for times_index in range(int(test_dict.get("times", 1))):
# suppose one testcase should not have more than 9999 steps,
# and one step should not run more than 999 times.
test_method_name = 'test_{:04}_{:03}'.format(index, times_index)
test_method = _add_teststep(test_runner, teststep_dict)
test_method = _add_test(test_runner, test_dict)
setattr(TestSequense, test_method_name, test_method)
loaded_testcase = self.test_loader.loadTestsFromTestCase(TestSequense)
setattr(loaded_testcase, "config", config)
setattr(loaded_testcase, "teststeps", teststeps)
setattr(loaded_testcase, "tests", tests)
setattr(loaded_testcase, "runner", test_runner)
test_suite.addTest(loaded_testcase)
@@ -221,7 +221,7 @@ def prepare_locust_tests(path):
functions = tests_mapping.get("project_mapping", {}).get("functions", {})
testcase = tests_mapping["testcases"][0]
items = testcase.get("teststeps", [])
items = testcase.get("tests", [])
tests = []
for item in items:

View File

@@ -17,11 +17,11 @@ class SessionContext(object):
def __init__(self, functions, variables=None):
self.session_variables_mapping = utils.ensure_mapping_format(variables or {})
self.FUNCTIONS_MAPPING = functions
self.teststep_variables_mapping = {}
self.init_teststep_variables()
self.test_variables_mapping = {}
self.init_test_variables()
def init_teststep_variables(self, variables_mapping=None):
""" init teststep variables, called when each teststep(api) starts.
def init_test_variables(self, variables_mapping=None):
""" init test variables, called when each test(api) starts.
variables_mapping will be evaluated first.
Args:
@@ -38,14 +38,14 @@ class SessionContext(object):
variables_mapping = utils.ensure_mapping_format(variables_mapping)
for variable_name, variable_value in variables_mapping.items():
variable_value = self.eval_content(variable_value)
self.update_teststep_variables(variable_name, variable_value)
self.update_test_variables(variable_name, variable_value)
self.teststep_variables_mapping.update(self.session_variables_mapping)
self.test_variables_mapping.update(self.session_variables_mapping)
def update_teststep_variables(self, variable_name, variable_value):
""" update teststep variables, these variables are only valid in the current teststep.
def update_test_variables(self, variable_name, variable_value):
""" update test variables, these variables are only valid in the current test.
"""
self.teststep_variables_mapping[variable_name] = variable_value
self.test_variables_mapping[variable_name] = variable_value
def update_seesion_variables(self, variables_mapping):
""" update session with extracted variables mapping.
@@ -53,7 +53,7 @@ class SessionContext(object):
"""
variables_mapping = utils.ensure_mapping_format(variables_mapping)
self.session_variables_mapping.update(variables_mapping)
self.teststep_variables_mapping.update(self.session_variables_mapping)
self.test_variables_mapping.update(self.session_variables_mapping)
def eval_content(self, content):
""" evaluate content recursively, take effect on each variable and function in content.
@@ -61,7 +61,7 @@ class SessionContext(object):
"""
return parser.parse_data(
content,
self.teststep_variables_mapping,
self.test_variables_mapping,
self.FUNCTIONS_MAPPING
)

View File

@@ -279,11 +279,11 @@ tests_def_mapping = {
"testcases": {}
}
def load_teststep(raw_stepinfo):
""" load teststep with api/testcase/proc references
def load_test(raw_testinfo):
""" load test with api/testcase/proc references
Args:
raw_stepinfo (dict): teststep data, maybe in 3 formats.
raw_testinfo (dict): test data, maybe in 3 formats.
# api reference
{
"name": "add product to cart",
@@ -308,24 +308,24 @@ def load_teststep(raw_stepinfo):
}
Returns:
list: loaded teststeps list
list: loaded tests list
Args:
raw_stepinfo (dict): teststep info
raw_testinfo (dict): test info
"""
# reference api
if "api" in raw_stepinfo:
api_name = raw_stepinfo["api"]
raw_stepinfo["api_def"] = _get_api_definition(api_name)
if "api" in raw_testinfo:
api_name = raw_testinfo["api"]
raw_testinfo["api_def"] = _get_api_definition(api_name)
# TODO: reference proc functions
elif "func" in raw_stepinfo:
elif "func" in raw_testinfo:
pass
# reference testcase
elif "testcase" in raw_stepinfo:
testcase_path = raw_stepinfo["testcase"]
elif "testcase" in raw_testinfo:
testcase_path = raw_testinfo["testcase"]
if testcase_path not in tests_def_mapping["testcases"]:
testcase_path = os.path.join(
@@ -337,13 +337,13 @@ def load_teststep(raw_stepinfo):
else:
testcase_dict = tests_def_mapping[testcase_path]
raw_stepinfo["testcase_def"] = testcase_dict
raw_testinfo["testcase_def"] = testcase_dict
# define directly
else:
pass
return raw_stepinfo
return raw_testinfo
def load_testcase(raw_testcase):
@@ -360,7 +360,7 @@ def load_testcase(raw_testcase):
"request": {}
}
},
# teststeps part
# tests part
{
"test": {...}
},
@@ -374,12 +374,12 @@ def load_testcase(raw_testcase):
{
"name": "XYZ",
"config": {},
"teststeps": [teststep11, teststep12]
"tests": [test11, test12]
}
"""
config = {}
teststeps = []
tests = []
for item in raw_testcase:
# TODO: add json schema validation
@@ -394,7 +394,7 @@ def load_testcase(raw_testcase):
config.update(test_block)
elif key == "test":
teststeps.append(load_teststep(test_block))
tests.append(load_test(test_block))
else:
logger.log_warning(
@@ -403,7 +403,7 @@ def load_testcase(raw_testcase):
return {
"config": config,
"teststeps": teststeps
"tests": tests
}
@@ -601,16 +601,16 @@ def load_tests(path, dot_env_path=None):
"path": "testcase1_path",
"variables": [], # optional
},
"teststeps": [
# teststep data structure
"tests": [
# test data structure
{
'name': 'test step desc1',
'name': 'test desc1',
'variables': [], # optional
'extract': [], # optional
'validate': [],
'request': {}
},
teststep2 # another teststep dict
test_dict_2 # another test dict
]
},
testcase_dict_2 # another testcase dict

View File

@@ -542,15 +542,15 @@ def parse_data(content, variables_mapping=None, functions_mapping=None):
return content
def _extend_with_api(teststep_dict, api_def_dict):
""" extend teststep with api definition, teststep will merge and override api definition.
def _extend_with_api(test_dict, api_def_dict):
""" extend test with api definition, test will merge and override api definition.
Args:
teststep_dict (dict): teststep block
test_dict (dict): test block
api_def_dict (dict): api definition
Returns:
dict: extended teststep dict.
dict: extended test dict.
Examples:
>>> api_def_dict = {
@@ -558,12 +558,12 @@ def _extend_with_api(teststep_dict, api_def_dict):
"request": {...},
"validate": [{'eq': ['status_code', 200]}]
}
>>> teststep_dict = {
>>> test_dict = {
"name": "get token 2",
"extract": [{"token": "content.token"}],
"validate": [{'eq': ['status_code', 201]}, {'len_eq': ['content.token', 16]}]
}
>>> _extend_with_api(teststep_dict, api_def_dict)
>>> _extend_with_api(test_dict, api_def_dict)
{
"name": "get token 2",
"request": {...},
@@ -574,18 +574,18 @@ def _extend_with_api(teststep_dict, api_def_dict):
"""
# override name
api_def_name = api_def_dict.pop("name", "")
teststep_dict["name"] = teststep_dict.get("name") or api_def_name
test_dict["name"] = test_dict.get("name") or api_def_name
# override variables
def_variables = api_def_dict.pop("variables", [])
teststep_dict["variables"] = utils.extend_variables(
test_dict["variables"] = utils.extend_variables(
def_variables,
teststep_dict.get("variables", {})
test_dict.get("variables", {})
)
# merge & override validators TODO: relocate
def_raw_validators = api_def_dict.pop("validate", [])
ref_raw_validators = teststep_dict.get("validate", [])
ref_raw_validators = test_dict.get("validate", [])
def_validators = [
parse_validator(validator)
for validator in def_raw_validators
@@ -594,86 +594,86 @@ def _extend_with_api(teststep_dict, api_def_dict):
parse_validator(validator)
for validator in ref_raw_validators
]
teststep_dict["validate"] = utils.extend_validators(
test_dict["validate"] = utils.extend_validators(
def_validators,
ref_validators
)
# merge & override extractors
def_extrators = api_def_dict.pop("extract", [])
teststep_dict["extract"] = utils.extend_variables(
test_dict["extract"] = utils.extend_variables(
def_extrators,
teststep_dict.get("extract", [])
test_dict.get("extract", [])
)
# TODO: merge & override request
teststep_dict["request"] = api_def_dict.pop("request", {})
test_dict["request"] = api_def_dict.pop("request", {})
# base_url
if "base_url" in teststep_dict:
base_url = teststep_dict.pop("base_url")
teststep_dict["request"]["url"] = utils.build_url(
if "base_url" in test_dict:
base_url = test_dict.pop("base_url")
test_dict["request"]["url"] = utils.build_url(
base_url,
teststep_dict["request"]["url"]
test_dict["request"]["url"]
)
# verify
if "verify" in teststep_dict:
verify = teststep_dict.pop("verify")
if "verify" in test_dict:
verify = test_dict.pop("verify")
elif "verify" in api_def_dict:
verify = api_def_dict.pop("verify")
else:
verify = True
teststep_dict["request"]["verify"] = verify
test_dict["request"]["verify"] = verify
# merge & override setup_hooks
def_setup_hooks = api_def_dict.pop("setup_hooks", [])
ref_setup_hooks = teststep_dict.get("setup_hooks", [])
ref_setup_hooks = test_dict.get("setup_hooks", [])
extended_setup_hooks = list(set(def_setup_hooks + ref_setup_hooks))
if extended_setup_hooks:
teststep_dict["setup_hooks"] = extended_setup_hooks
test_dict["setup_hooks"] = extended_setup_hooks
# merge & override teardown_hooks
def_teardown_hooks = api_def_dict.pop("teardown_hooks", [])
ref_teardown_hooks = teststep_dict.get("teardown_hooks", [])
ref_teardown_hooks = test_dict.get("teardown_hooks", [])
extended_teardown_hooks = list(set(def_teardown_hooks + ref_teardown_hooks))
if extended_teardown_hooks:
teststep_dict["teardown_hooks"] = extended_teardown_hooks
test_dict["teardown_hooks"] = extended_teardown_hooks
# TODO: extend with other api definition items, e.g. times
teststep_dict.update(api_def_dict)
test_dict.update(api_def_dict)
return teststep_dict
return test_dict
def _extend_with_testcase(teststep_dict, testcase_def_dict):
""" extend teststep with testcase definition
teststep will merge and override testcase config definition.
def _extend_with_testcase(test_dict, testcase_def_dict):
""" extend test with testcase definition
test will merge and override testcase config definition.
Args:
teststep_dict (dict): teststep block
test_dict (dict): test block
testcase_def_dict (dict): testcase definition
Returns:
dict: extended teststep dict.
dict: extended test dict.
"""
# override testcase config variables
testcase_def_dict["config"].setdefault("variables", {})
testcase_def_variables = utils.ensure_mapping_format(testcase_def_dict["config"].get("variables", {}))
testcase_def_variables.update(teststep_dict.pop("variables", {}))
testcase_def_variables.update(test_dict.pop("variables", {}))
testcase_def_dict["config"]["variables"] = testcase_def_variables
# override base_url, verify
# priority: testcase config > testsuite teststep
teststep_base_url = teststep_dict.pop("base_url", None)
teststep_verify = teststep_dict.pop("verify", True)
testcase_def_dict["config"].setdefault("base_url", teststep_base_url)
testcase_def_dict["config"].setdefault("verify", teststep_verify)
# priority: testcase config > testsuite tests
test_base_url = test_dict.pop("base_url", None)
test_verify = test_dict.pop("verify", True)
testcase_def_dict["config"].setdefault("base_url", test_base_url)
testcase_def_dict["config"].setdefault("verify", test_verify)
# override testcase config name, output, etc.
testcase_def_dict["config"].update(teststep_dict)
testcase_def_dict["config"].update(test_dict)
teststep_dict.clear()
teststep_dict.update(testcase_def_dict)
test_dict.clear()
test_dict.update(testcase_def_dict)
def __parse_config(config, project_mapping):
@@ -722,22 +722,22 @@ def __parse_config(config, project_mapping):
)
def __parse_teststeps(teststeps, config, project_mapping):
""" override teststeps with testcase config variables, base_url and verify.
teststep maybe nested testcase.
def __parse_tests(tests, config, project_mapping):
""" override tests with testcase config variables, base_url and verify.
test maybe nested testcase.
variables priority:
testsuite config > testsuite teststep > testcase config > testcase teststep > api
testsuite config > testsuite test > testcase config > testcase test > api
base_url/verify priority:
testcase teststep > testcase config > testsuite teststep > testsuite config > api
testcase test > testcase config > testsuite test > testsuite config > api
Args:
teststeps (list):
tests (list):
config (dict):
Returns:
list: overrided teststeps
list: overrided tests
"""
config_variables = config.pop("variables", {})
@@ -745,80 +745,80 @@ def __parse_teststeps(teststeps, config, project_mapping):
config_verify = config.pop("verify", True)
functions = project_mapping.get("functions", {})
for teststep in teststeps:
for test_dict in tests:
# base_url & verify: priority teststep > config
# base_url & verify: priority test_dict > config
if config_base_url:
teststep.setdefault("base_url", config_base_url)
teststep.setdefault("verify", config_verify)
test_dict.setdefault("base_url", config_base_url)
test_dict.setdefault("verify", config_verify)
if "testcase_def" in teststep:
# teststep is nested testcase
if "testcase_def" in test_dict:
# test_dict is nested testcase
# 1, testsuite config => testsuite teststeps
# override teststep variables
teststep["variables"] = utils.extend_variables(
teststep.pop("variables", {}),
# 1, testsuite config => testsuite tests
# override test_dict variables
test_dict["variables"] = utils.extend_variables(
test_dict.pop("variables", {}),
config_variables
)
# parse teststep name
# parse test_dict name
try:
teststep["name"] = parse_data(
teststep.pop("name", ""),
teststep["variables"],
test_dict["name"] = parse_data(
test_dict.pop("name", ""),
test_dict["variables"],
functions
)
except exceptions.VariableNotFound:
pass
# 2, testsuite teststep => testcase config
testcase_def = teststep.pop("testcase_def")
_extend_with_testcase(teststep, testcase_def)
# 2, testsuite test_dict => testcase config
testcase_def = test_dict.pop("testcase_def")
_extend_with_testcase(test_dict, testcase_def)
# 3, testcase config => testcase teststep
_parse_testcase(teststep, project_mapping)
# 3, testcase config => testcase test_dict
_parse_testcase(test_dict, project_mapping)
else:
# teststep is API test, has two cases.
# (1) teststep has API reference
# (2) teststep is defined directly
# test_dict is API test, has two cases.
# (1) test_dict has API reference
# (2) test_dict is defined directly
# 1, config => teststeps
# override teststep variables
teststep["variables"] = utils.extend_variables(
teststep.pop("variables", {}),
# 1, config => tests
# override test_dict variables
test_dict["variables"] = utils.extend_variables(
test_dict.pop("variables", {}),
config_variables
)
# parse teststep name
# parse test_dict name
try:
teststep["name"] = parse_data(
teststep.pop("name", ""),
teststep["variables"],
test_dict["name"] = parse_data(
test_dict.pop("name", ""),
test_dict["variables"],
functions
)
except exceptions.VariableNotFound:
pass
if "api_def" in teststep:
if "api_def" in test_dict:
# case (1)
# 2, teststep => api
api_def_dict = teststep.pop("api_def")
_extend_with_api(teststep, api_def_dict)
# 2, test_dict => api
api_def_dict = test_dict.pop("api_def")
_extend_with_api(test_dict, api_def_dict)
else:
# case (2)
if "base_url" in teststep:
base_url = teststep.pop("base_url")
teststep["request"]["url"] = utils.build_url(
if "base_url" in test_dict:
base_url = test_dict.pop("base_url")
test_dict["request"]["url"] = utils.build_url(
base_url,
teststep["request"]["url"]
test_dict["request"]["url"]
)
def _parse_testcase(testcase, project_mapping):
__parse_config(testcase["config"], project_mapping)
__parse_teststeps(testcase["teststeps"], testcase["config"], project_mapping)
__parse_tests(testcase["tests"], testcase["config"], project_mapping)
def parse_tests(tests_mapping):
@@ -841,8 +841,8 @@ def parse_tests(tests_mapping):
"path": "testcase1_path",
"variables": [], # optional, priority 2
},
"teststeps": [
# teststep data structure
"tests": [
# test data structure
{
'name': 'test step desc1',
'variables': [], # optional, priority 3
@@ -853,7 +853,7 @@ def parse_tests(tests_mapping):
'request': {},
}
},
teststep2 # another teststep dict
test_dict_2 # another test dict
]
},
testcase_dict_2 # another testcase dict

View File

@@ -19,15 +19,15 @@ class Runner(object):
}
>>> runner = Runner(config, functions)
>>> teststep = {
"name": "teststep description",
>>> test_dict = {
"name": "test description",
"variables": [], # optional
"request": {
"url": "http://127.0.0.1:5000/api/users/1000",
"method": "GET"
}
}
>>> runner.run_test(teststep)
>>> runner.run_test(test_dict)
"""
@@ -68,32 +68,32 @@ class Runner(object):
if self.testcase_teardown_hooks:
self.do_hook_actions(self.testcase_teardown_hooks)
def _handle_skip_feature(self, teststep_dict):
""" handle skip feature for teststep
def _handle_skip_feature(self, test_dict):
""" handle skip feature for test
- skip: skip current test unconditionally
- skipIf: skip current test if condition is true
- skipUnless: skip current test unless condition is true
Args:
teststep_dict (dict): teststep info
test_dict (dict): test info
Raises:
SkipTest: skip teststep
SkipTest: skip test
"""
# TODO: move skip to initialize
skip_reason = None
if "skip" in teststep_dict:
skip_reason = teststep_dict["skip"]
if "skip" in test_dict:
skip_reason = test_dict["skip"]
elif "skipIf" in teststep_dict:
skip_if_condition = teststep_dict["skipIf"]
elif "skipIf" in test_dict:
skip_if_condition = test_dict["skipIf"]
if self.session_context.eval_content(skip_if_condition):
skip_reason = "{} evaluate to True".format(skip_if_condition)
elif "skipUnless" in teststep_dict:
skip_unless_condition = teststep_dict["skipUnless"]
elif "skipUnless" in test_dict:
skip_unless_condition = test_dict["skipUnless"]
if not self.session_context.eval_content(skip_unless_condition):
skip_reason = "{} evaluate to False".format(skip_unless_condition)
@@ -106,11 +106,11 @@ class Runner(object):
# TODO: check hook function if valid
self.session_context.eval_content(action)
def _run_teststep(self, teststep_dict):
def _run_test(self, test_dict):
""" run single teststep.
Args:
teststep_dict (dict): teststep info
test_dict (dict): teststep info
{
"name": "teststep description",
"skip": "skip this test unconditionally",
@@ -139,28 +139,28 @@ class Runner(object):
"""
# check skip
self._handle_skip_feature(teststep_dict)
self._handle_skip_feature(test_dict)
# prepare
teststep_dict = utils.lower_test_dict_keys(teststep_dict)
teststep_variables = teststep_dict.get("variables", {})
self.session_context.init_teststep_variables(teststep_variables)
test_dict = utils.lower_test_dict_keys(test_dict)
test_variables = test_dict.get("variables", {})
self.session_context.init_test_variables(test_variables)
# parse teststep request
raw_request = teststep_dict.get('request', {})
parsed_teststep_request = self.session_context.eval_content(raw_request)
self.session_context.update_teststep_variables("request", parsed_teststep_request)
# parse test request
raw_request = test_dict.get('request', {})
parsed_test_request = self.session_context.eval_content(raw_request)
self.session_context.update_test_variables("request", parsed_test_request)
# setup hooks
setup_hooks = teststep_dict.get("setup_hooks", [])
setup_hooks = test_dict.get("setup_hooks", [])
setup_hooks.insert(0, "${setup_hook_prepare_kwargs($request)}")
self.do_hook_actions(setup_hooks)
try:
url = parsed_teststep_request.pop('url')
method = parsed_teststep_request.pop('method')
parsed_teststep_request.setdefault("verify", self.verify)
group_name = parsed_teststep_request.pop("group", None)
url = parsed_test_request.pop('url')
method = parsed_test_request.pop('method')
parsed_test_request.setdefault("verify", self.verify)
group_name = parsed_test_request.pop("group", None)
except KeyError:
raise exceptions.ParamsError("URL or METHOD missed!")
@@ -173,38 +173,38 @@ class Runner(object):
raise exceptions.ParamsError(err_msg)
logger.log_info("{method} {url}".format(method=method, url=url))
logger.log_debug("request kwargs(raw): {kwargs}".format(kwargs=parsed_teststep_request))
logger.log_debug("request kwargs(raw): {kwargs}".format(kwargs=parsed_test_request))
# request
resp = self.http_client_session.request(
method,
url,
name=group_name,
**parsed_teststep_request
**parsed_test_request
)
resp_obj = response.ResponseObject(resp)
# teardown hooks
teardown_hooks = teststep_dict.get("teardown_hooks", [])
teardown_hooks = test_dict.get("teardown_hooks", [])
if teardown_hooks:
logger.log_info("start to run teardown hooks")
self.session_context.update_teststep_variables("response", resp_obj)
self.session_context.update_test_variables("response", resp_obj)
self.do_hook_actions(teardown_hooks)
# extract
extractors = teststep_dict.get("extract", [])
extractors = test_dict.get("extract", [])
extracted_variables_mapping = resp_obj.extract_response(extractors)
self.session_context.update_seesion_variables(extracted_variables_mapping)
# validate
validators = teststep_dict.get("validate", [])
validators = test_dict.get("validate", [])
try:
self.evaluated_validators = self.session_context.validate(validators, resp_obj)
except (exceptions.ParamsError, exceptions.ValidationFailure, exceptions.ExtractFailure):
# log request
err_req_msg = "request: \n"
err_req_msg += "headers: {}\n".format(parsed_teststep_request.pop("headers", {}))
for k, v in parsed_teststep_request.items():
err_req_msg += "headers: {}\n".format(parsed_test_request.pop("headers", {}))
for k, v in parsed_test_request.items():
err_req_msg += "{}: {}\n".format(k, repr(v))
logger.log_error(err_req_msg)
@@ -223,18 +223,18 @@ class Runner(object):
config = testcase_dict.get("config", {})
test_runner = Runner(config, self.functions, self.http_client_session)
teststeps = testcase_dict.get("teststeps", [])
for index, teststep_dict in enumerate(teststeps):
test_runner.run_test(teststep_dict)
tests = testcase_dict.get("tests", [])
for index, test_dict in enumerate(tests):
test_runner.run_test(test_dict)
self.session_context.update_seesion_variables(test_runner.extract_sessions())
def run_test(self, teststep_dict):
def run_test(self, test_dict):
""" run single teststep of testcase.
teststep_dict may be in 3 types.
test_dict may be in 3 types.
Args:
teststep_dict (dict):
test_dict (dict):
# teststep
{
@@ -249,7 +249,7 @@ class Runner(object):
# embeded testcase
{
"config": {...},
"teststeps": [
"tests": [
{...},
{...}
]
@@ -262,11 +262,11 @@ class Runner(object):
}
"""
if "config" in teststep_dict:
self._run_testcase(teststep_dict)
if "config" in test_dict:
self._run_testcase(test_dict)
else:
# api
self._run_teststep(teststep_dict)
self._run_test(test_dict)
def extract_sessions(self):
"""

View File

@@ -19,9 +19,9 @@ def is_testcase(data_structure):
"variables": [], # optional
"request": {} # optional
},
"teststeps": [
teststep1,
{ # teststep2
"tests": [
test_dict1,
{ # test_dict2
'name': 'test step desc2',
'variables': [], # optional
'extract': [], # optional
@@ -40,10 +40,10 @@ def is_testcase(data_structure):
if not isinstance(data_structure, dict):
return False
if "teststeps" not in data_structure:
if "tests" not in data_structure:
return False
if not isinstance(data_structure["teststeps"], list):
if not isinstance(data_structure["tests"], list):
return False
return True
@@ -67,8 +67,8 @@ def is_testcases(data_structure):
"path": "testcase1_path",
"variables": [], # optional
},
"teststeps": [
# teststep data structure
"tests": [
# test data structure
{
'name': 'test step desc1',
'variables': [], # optional
@@ -76,7 +76,7 @@ def is_testcases(data_structure):
'validate': [],
'request': {}
},
teststep2 # another teststep dict
test_dict_2 # another test dict
]
},
testcase_dict_2 # another testcase dict