From 3b2952d322e0dcad09a97bd0fe7f956e218e229f Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 17 Mar 2022 10:42:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=90=8C=E5=90=8D=E5=9C=BA=E6=99=AF=E5=8F=98=E9=87=8F=E5=92=8C?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E5=8C=B9=E9=85=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99=E8=B0=83=E6=95=B4=E5=9C=BA=E6=99=AF=E6=9C=80=E4=BC=98?= =?UTF-8?q?=E5=85=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1011057 --user=赵勇 【接口测试】github#11350,场景变量没有大于全局变量 https://www.tapd.cn/55049933/s/1119671 --- .../dto/definition/request/MsScenario.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 2ba6e2a1ab..c2c4c0a72c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -307,15 +307,7 @@ public class MsScenario extends MsTestElement { arguments.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "Arguments"); arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName()); arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel")); - // 环境通用变量 - if (config.isEffective(this.getProjectId()) && config.getConfig().get(this.getProjectId()).getCommonConfig() != null - && CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables())) { - config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> - arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") - ); - // 清空变量,防止重复添加 - config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().clear(); - } + // 场景变量 if (CollectionUtils.isNotEmpty(this.getVariables())) { this.getVariables().stream().filter(ScenarioVariable::isConstantValid).forEach(keyValue -> arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") @@ -329,6 +321,15 @@ public class MsScenario extends MsTestElement { } }); } + // 环境通用变量 + if (config.isEffective(this.getProjectId()) && config.getConfig().get(this.getProjectId()).getCommonConfig() != null + && CollectionUtils.isNotEmpty(config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables())) { + config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue -> + arguments.addArgument(keyValue.getName(), keyValue.getValue(), "=") + ); + // 清空变量,防止重复添加 + config.getConfig().get(this.getProjectId()).getCommonConfig().getVariables().clear(); + } if (arguments.getArguments() != null && arguments.getArguments().size() > 0) { return arguments; }