fix(接口定义): 修复场景跨项目执行无法保存别的项目的环境变量的缺陷

--bug=1022043 --user=王孝刚
【接口测试】github#21345,使用环境组执行场景用例,不能保存数据到另外一个项目的环境变量
https://www.tapd.cn/55049933/s/1328097
This commit is contained in:
wxg0103 2023-01-18 14:03:55 +08:00 committed by 刘瑞斌
parent 517b3e32dc
commit 95f1fd1450
4 changed files with 6 additions and 6 deletions

View File

@ -876,11 +876,11 @@ public class ElementUtil {
}
}
public static String getScriptEnv(String environmentId, ParameterConfig config) {
public static String getScriptEnv(String environmentId, ParameterConfig config, String projectId) {
if (StringUtils.isEmpty(environmentId)) {
if (config.getConfig() != null) {
if (config.getProjectId() != null && config.getConfig().containsKey(config.getProjectId())) {
return config.getConfig().get(config.getProjectId()).getEnvironmentId();
if (StringUtils.isNotBlank(projectId) && config.getConfig().containsKey(projectId)) {
return config.getConfig().get(projectId).getEnvironmentId();
} else {
if (CollectionUtils.isNotEmpty(config.getConfig().values())) {
Optional<EnvironmentConfig> values = config.getConfig().entrySet().stream().findFirst().map(Map.Entry::getValue);

View File

@ -44,7 +44,7 @@ public class MsJSR223Processor extends MsTestElement {
if (!config.isOperating() && !this.isEnable()) {
return;
}
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config));
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId()));
TestElement processor = new BeanShellSampler();
if (jsrEnable == null || BooleanUtils.isTrue(jsrEnable)) {

View File

@ -43,7 +43,7 @@ public class MsJSR223PostProcessor extends MsTestElement {
if (!config.isOperating() && !this.isEnable()) {
return;
}
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config));
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId()));
TestElement processor = new BeanShellPostProcessor();
if (jsrEnable == null || BooleanUtils.isTrue(jsrEnable)) {

View File

@ -43,7 +43,7 @@ public class MsJSR223PreProcessor extends MsTestElement {
}
}
ScriptFilter.verify(this.getScriptLanguage(), this.getName(), script);
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config));
this.setEnvironmentId(ElementUtil.getScriptEnv(this.getEnvironmentId(), config, this.getProjectId()));
final HashTree jsr223PreTree = tree.add(getShellProcessor());
if (CollectionUtils.isNotEmpty(hashTree)) {