fix(测试跟踪): 导入场景全局环境变量失效问题
【【测试跟踪】github#34733,重新导入场景,全局前置脚本不执行】 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001050667
This commit is contained in:
parent
2cc45e88cb
commit
c0660e8827
|
@ -166,29 +166,38 @@ 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();
|
MsJSR223Processor processor = new MsJSR223Processor();
|
||||||
MsJSR223Processor processor = new MsJSR223Processor();
|
if (envProcessor != null) {
|
||||||
if (envProcessor != null) {
|
BeanUtils.copyBean(processor, envProcessor);
|
||||||
BeanUtils.copyBean(processor, envProcessor);
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(processor.getScript())) {
|
|
||||||
processor.setType(ElementConstants.JSR223);
|
|
||||||
processor.setClazzName(MsJSR223Processor.class.getCanonicalName());
|
|
||||||
boolean isConnScenarioPre = false;
|
|
||||||
if (environmentConfig.getGlobalScriptConfig() != null) {
|
|
||||||
isConnScenarioPre = isPre ? environmentConfig.getGlobalScriptConfig().isConnScenarioPreScript() :
|
|
||||||
environmentConfig.getGlobalScriptConfig().isConnScenarioPostScript();
|
|
||||||
}
|
|
||||||
String name = isPre ? "PRE_PROCESSOR_ENV_" : "POST_PROCESSOR_ENV_";
|
|
||||||
processor.setName(name + isConnScenarioPre);
|
|
||||||
processor.toHashTree(scenarioTree, processor.getHashTree(), config);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
if (StringUtils.isNotEmpty(processor.getScript())) {
|
||||||
|
processor.setType(ElementConstants.JSR223);
|
||||||
|
processor.setClazzName(MsJSR223Processor.class.getCanonicalName());
|
||||||
|
boolean isConnScenarioPre = false;
|
||||||
|
if (environmentConfig.getGlobalScriptConfig() != null) {
|
||||||
|
isConnScenarioPre = isPre ? environmentConfig.getGlobalScriptConfig().isConnScenarioPreScript() :
|
||||||
|
environmentConfig.getGlobalScriptConfig().isConnScenarioPostScript();
|
||||||
|
}
|
||||||
|
String name = isPre ? "PRE_PROCESSOR_ENV_" : "POST_PROCESSOR_ENV_";
|
||||||
|
processor.setName(name + isConnScenarioPre);
|
||||||
|
processor.toHashTree(scenarioTree, processor.getHashTree(), config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue