mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
feat: 'export' is used to replace 'output' in testcase config
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
**Features**
|
||||
|
||||
- `extract` is used to replace `output` when passing former teststep's (as a testcase) export value to next teststep
|
||||
- `export` is used to replace `output` in testcase config
|
||||
|
||||
## 2.2.1 (2019-06-25)
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class Runner(object):
|
||||
|
||||
"""
|
||||
self.verify = config.get("verify", True)
|
||||
self.output = config.get("output", [])
|
||||
self.export = config.get("export") or config.get("output", [])
|
||||
self.validation_results = []
|
||||
config_variables = config.get("variables", {})
|
||||
|
||||
@@ -327,7 +327,7 @@ class Runner(object):
|
||||
self.meta_datas.append(_meta_datas)
|
||||
|
||||
self.session_context.update_session_variables(
|
||||
test_runner.extract_output(test_runner.output)
|
||||
test_runner.export_variables(test_runner.export)
|
||||
)
|
||||
|
||||
def run_test(self, test_dict):
|
||||
@@ -382,8 +382,8 @@ class Runner(object):
|
||||
finally:
|
||||
self.meta_datas = self.__get_test_data()
|
||||
|
||||
def extract_output(self, output_variables_list):
|
||||
""" extract output variables
|
||||
def export_variables(self, output_variables_list):
|
||||
""" export current testcase variables
|
||||
"""
|
||||
variables_mapping = self.session_context.session_variables_mapping
|
||||
|
||||
@@ -391,7 +391,7 @@ class Runner(object):
|
||||
for variable in output_variables_list:
|
||||
if variable not in variables_mapping:
|
||||
logger.log_warning(
|
||||
"variable '{}' can not be found in variables mapping, failed to output!"\
|
||||
"variable '{}' can not be found in variables mapping, failed to export!"\
|
||||
.format(variable)
|
||||
)
|
||||
continue
|
||||
|
||||
@@ -328,7 +328,7 @@ def extend_variables(raw_variables, override_variables):
|
||||
|
||||
|
||||
def get_testcase_io(testcase):
|
||||
""" get and print testcase input(variables) and output.
|
||||
""" get and print testcase input(variables) and output(export).
|
||||
|
||||
Args:
|
||||
testcase (unittest.suite.TestSuite): corresponding to one YAML/JSON file, it has been set two attributes:
|
||||
@@ -340,12 +340,13 @@ def get_testcase_io(testcase):
|
||||
"""
|
||||
test_runner = testcase.runner
|
||||
variables = testcase.config.get("variables", {})
|
||||
output_list = testcase.config.get("output", [])
|
||||
output_mapping = test_runner.extract_output(output_list)
|
||||
output_list = testcase.config.get("export") \
|
||||
or testcase.config.get("output", [])
|
||||
export_mapping = test_runner.export_variables(output_list)
|
||||
|
||||
return {
|
||||
"in": variables,
|
||||
"out": output_mapping
|
||||
"out": export_mapping
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
os_platform: 'ios'
|
||||
app_version: '2.8.6'
|
||||
base_url: ${get_base_url()}
|
||||
output:
|
||||
export:
|
||||
- token
|
||||
|
||||
- test:
|
||||
|
||||
@@ -93,7 +93,7 @@ class TestHttpRunner(ApiServerUnittest):
|
||||
"var1": "abc",
|
||||
"var2": "def"
|
||||
},
|
||||
"output": ["status_code", "req_data"]
|
||||
"export": ["status_code", "req_data"]
|
||||
},
|
||||
"teststeps": [
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ config:
|
||||
variables:
|
||||
uid: 9001
|
||||
device_sn: "TESTCASE_CREATE_XXX"
|
||||
output:
|
||||
export:
|
||||
- session_token
|
||||
|
||||
teststeps:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
variables:
|
||||
uid: 9001
|
||||
device_sn: "TESTCASE_CREATE_XXX"
|
||||
output:
|
||||
export:
|
||||
- session_token
|
||||
|
||||
- test:
|
||||
|
||||
@@ -8,7 +8,7 @@ config:
|
||||
app_version: '2.8.6'
|
||||
base_url: "http://127.0.0.1:5000"
|
||||
verify: False
|
||||
output:
|
||||
export:
|
||||
- session_token
|
||||
|
||||
teststeps:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
app_version: '2.8.6'
|
||||
base_url: "http://127.0.0.1:5000"
|
||||
verify: False
|
||||
output:
|
||||
export:
|
||||
- session_token
|
||||
|
||||
- test:
|
||||
|
||||
Reference in New Issue
Block a user