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