fix(接口测试): 修复场景变量隔离问题

--bug=1012107 --user=赵勇 【接口测试】github#12512,场景变量引用不对 https://www.tapd.cn/55049933/s/1138047
This commit is contained in:
fit2-zhao 2022-04-18 15:28:52 +08:00 committed by 刘瑞斌
parent 4add00720e
commit a0880b35e1
1 changed files with 3 additions and 2 deletions

View File

@ -149,9 +149,10 @@ public class MsScenario extends MsTestElement {
if (arguments != null && (this.variableEnable == null || this.variableEnable)) { if (arguments != null && (this.variableEnable == null || this.variableEnable)) {
Arguments valueSupposeMock = ParameterConfig.valueSupposeMock(arguments); Arguments valueSupposeMock = ParameterConfig.valueSupposeMock(arguments);
// 这里加入自定义变量解决ForEach循环控制器取值问题循环控制器无法从vars中取值 // 这里加入自定义变量解决ForEach循环控制器取值问题循环控制器无法从vars中取值
scenarioTree.add(valueSupposeMock);
if (this.variableEnable != null && this.variableEnable) { if (this.variableEnable != null && this.variableEnable) {
scenarioTree.add(ElementUtil.argumentsToUserParameters(valueSupposeMock)); scenarioTree.add(ElementUtil.argumentsToUserParameters(valueSupposeMock));
} else {
scenarioTree.add(valueSupposeMock);
} }
} }
if (this.variableEnable == null || this.variableEnable) { if (this.variableEnable == null || this.variableEnable) {
@ -261,7 +262,7 @@ public class MsScenario extends MsTestElement {
if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) { if (StringUtils.equals(environmentType, EnvironmentType.GROUP.name())) {
this.environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId); this.environmentMap = environmentGroupProjectService.getEnvMap(environmentGroupId);
} else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) { } else if (StringUtils.equals(environmentType, EnvironmentType.JSON.name())) {
this.environmentMap = JSON.parseObject(environmentJson, Map.class,Feature.DisableSpecialKeyDetect); this.environmentMap = JSON.parseObject(environmentJson, Map.class, Feature.DisableSpecialKeyDetect);
} }
} else { } else {
this.setEnvironmentEnable(false); this.setEnvironmentEnable(false);