From 17238af7778bb4ffae603500870808619e32c37f Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 29 Jun 2023 17:06:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E5=8F=98=E9=87=8F=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=80=BC=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E6=8A=A5=E9=94=99=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1027469 --user=王孝刚 【接口测试】场景详情-场景变量值为空-未引用场景变量-调试场景报错 https://www.tapd.cn/55049933/s/1388281 --- .../api/dto/definition/request/ElementUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 13ae3330e9..eb87995ebc 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -738,7 +738,8 @@ public class ElementUtil { variables.stream() .filter(ScenarioVariable::isConstantValid).forEach(keyValue -> arguments.addArgument(keyValue.getName(), - keyValue.getValue().replaceAll("[\r\n]",""), "=")); + StringUtils.isNotBlank(keyValue.getValue()) + ? keyValue.getValue().replaceAll("[\r\n]","") : keyValue.getValue(), "=")); List variableList = variables.stream() .filter(ScenarioVariable::isListValid).collect(Collectors.toList()); variableList.forEach(item -> { @@ -761,7 +762,9 @@ public class ElementUtil { arguments.addArgument(keyValue.getName(), keyValue.getValue() != null && keyValue.getValue().startsWith("@") ? ScriptEngineUtils.buildFunctionCallString(keyValue.getValue()) - : keyValue.getValue().replaceAll("[\r\n]",""), "=")); + : (StringUtils.isNotBlank(keyValue.getValue()) + ? keyValue.getValue().replaceAll("[\r\n]","") + : keyValue.getValue()), "=")); // List类型的变量 List variableList = config.getConfig().get(projectId).getCommonConfig().getVariables().stream() .filter(ScenarioVariable::isListValid)