fix(测试跟踪): 导入场景全局环境变量失效问题

【【测试跟踪】github#34733,重新导入场景,全局前置脚本不执行】
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001050667
This commit is contained in:
fit2-zhao 2024-12-19 18:42:52 +08:00 committed by Craftsman
parent 2cc45e88cb
commit c0660e8827
1 changed files with 32 additions and 23 deletions

View File

@ -166,8 +166,7 @@ public class MsScenario extends MsTestElement {
&& (this.mixEnable == null || BooleanUtils.isFalse(this.mixEnable)); && (this.mixEnable == null || BooleanUtils.isFalse(this.mixEnable));
} }
private void setGlobProcessor(ParameterConfig config, HashTree scenarioTree, boolean isPre) { private void setConfig(ParameterConfig config, HashTree scenarioTree, boolean isPre) {
if (config.getConfig() != null && (this.variableEnable == null || this.variableEnable)) {
config.getConfig().forEach((k, environmentConfig) -> { config.getConfig().forEach((k, environmentConfig) -> {
if (environmentConfig != null) { if (environmentConfig != null) {
EnvJSR223Processor envProcessor = isPre ? environmentConfig.getPreStepProcessor() : environmentConfig.getPostStepProcessor(); EnvJSR223Processor envProcessor = isPre ? environmentConfig.getPreStepProcessor() : environmentConfig.getPostStepProcessor();
@ -190,6 +189,16 @@ public class MsScenario extends MsTestElement {
} }
}); });
} }
private void setGlobProcessor(ParameterConfig config, HashTree scenarioTree, boolean isPre) {
if (config.getConfig() != null) {
if (StringUtils.equals(this.getId(), config.getScenarioId())) {
setConfig(config, scenarioTree, isPre);
} else if (this.variableEnable == null || this.variableEnable) {
setConfig(config, scenarioTree, isPre);
}
}
} }
private boolean setRefScenario(List<MsTestElement> hashTree) { private boolean setRefScenario(List<MsTestElement> hashTree) {
@ -222,7 +231,7 @@ public class MsScenario extends MsTestElement {
return false; return false;
} }
private void setNewConfig( ParameterConfig newConfig) { private void setNewConfig(ParameterConfig newConfig) {
Map<String, EnvironmentConfig> envConfig = new HashMap<>(); Map<String, EnvironmentConfig> envConfig = new HashMap<>();
if (this.isEnvironmentEnable()) { if (this.isEnvironmentEnable()) {
ApiScenarioMapper apiScenarioMapper = CommonBeanFactory.getBean(ApiScenarioMapper.class); ApiScenarioMapper apiScenarioMapper = CommonBeanFactory.getBean(ApiScenarioMapper.class);