fix: step name overrides reference testcase name

This commit is contained in:
xucong053
2022-06-17 18:20:22 +08:00
parent 1dd1f617b2
commit a85ba43bf9
2 changed files with 9 additions and 3 deletions

View File

@@ -46,6 +46,7 @@ class SessionRunner(object):
__export: List[Text] = []
__step_results: List[StepResult] = []
__session_variables: VariablesMapping = {}
__is_reference: bool = False
# time
__start_at: float = 0
__duration: float = 0
@@ -58,6 +59,7 @@ class SessionRunner(object):
self.__session_variables = self.__session_variables or {}
self.__start_at = 0
self.__duration = 0
self.__is_reference = self.__is_reference or False
self.__project_meta = self.__project_meta or load_project_meta(
self.__config.path
@@ -77,6 +79,10 @@ class SessionRunner(object):
def get_config(self) -> TConfig:
return self.__config
def set_references(self) -> "SessionRunner":
self.__is_reference = True
return self
def with_case_id(self, case_id: Text) -> "SessionRunner":
self.case_id = case_id
return self
@@ -193,7 +199,7 @@ class SessionRunner(object):
)
time.sleep(step.retry_interval)
logger.info(
f"run step retry ({i+1}/{step.retry_times} time): {step.name()} >>>>>>"
f"run step retry ({i + 1}/{step.retry_times} time): {step.name()} >>>>>>"
)
# save extracted variables to session variables
@@ -209,7 +215,7 @@ class SessionRunner(object):
self.__init()
self.__parse_config(param)
if USE_ALLURE:
if USE_ALLURE and not self.__is_reference:
# update allure report meta
allure.dynamic.title(self.__config.name)
allure.dynamic.description(f"TestCase ID: {self.case_id}")

View File

@@ -22,7 +22,7 @@ def run_step_testcase(runner: HttpRunner, step: TStep) -> StepResult:
# step.testcase is a referenced testcase, e.g. RequestWithFunctions
ref_case_runner = step.testcase()
ref_case_runner.with_session(runner.session).with_case_id(
ref_case_runner.set_references().with_session(runner.session).with_case_id(
runner.case_id
).with_variables(step_variables).with_export(step_export).test_start()