From 84ea8bf112990ba30a2a2a52b2d37fb8d01109a0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 6 Jan 2023 09:36:04 +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=E6=AD=A5=E9=AA=A4=E5=8D=95?= =?UTF-8?q?=E6=AD=A5=E8=B0=83=E8=AF=95=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021620 --user=赵勇 【接口测试】github#21116,接口自动化场景中,单独执行用例 不能调用环境变量,旧版本是正常的 https://www.tapd.cn/55049933/s/1323348 --- .../io/metersphere/api/dto/definition/request/MsScenario.java | 3 ++- .../api/dto/definition/request/ParameterConfig.java | 2 +- .../java/io/metersphere/api/exec/api/ApiExecuteService.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index 009e233ead..1950f0a10d 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -127,7 +127,8 @@ public class MsScenario extends MsTestElement { // 这里加入自定义变量解决ForEach循环控制器取值问题,循环控制器无法从vars中取值 if (BooleanUtils.isTrue(this.variableEnable) || BooleanUtils.isTrue(this.mixEnable)) { scenarioTree.add(ElementUtil.argumentsToUserParameters(valueSupposeMock)); - } else if (config != null && StringUtils.equals(this.getId(), config.getScenarioId())) { + } else if (config != null + && (StringUtils.equals(this.getId(), config.getScenarioId()) || config.isApi())) { scenarioTree.add(valueSupposeMock); } } diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java index 54a74a694b..6914302372 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java @@ -92,7 +92,7 @@ public class ParameterConfig extends MsParameter { private boolean runLocal; private String browserLanguage; - + private boolean isApi; /** * 排除生成临界控制器的场景 */ diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index 5a77a61e4e..6b54e0049d 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -204,7 +204,7 @@ public class ApiExecuteService { private JmeterRunRequestDTO initRunRequest(RunDefinitionRequest request, List bodyFiles) { ParameterConfig config = new ParameterConfig(); config.setProjectId(request.getProjectId()); - + config.setApi(true); Map envConfig = new HashMap<>(); Map map = request.getEnvironmentMap(); if (map != null && map.size() > 0) { @@ -308,7 +308,7 @@ public class ApiExecuteService { BaseEnvironmentService apiTestEnvironmentService = CommonBeanFactory.getBean(BaseEnvironmentService.class); ApiTestEnvironmentWithBLOBs environment = apiTestEnvironmentService.get(request.getEnvironmentId()); ParameterConfig parameterConfig = new ParameterConfig(); - + parameterConfig.setApi(true); Map envConfig = new HashMap<>(16); if (environment != null && environment.getConfig() != null) { EnvironmentConfig environmentConfig = JSONUtil.parseObject(environment.getConfig(), EnvironmentConfig.class);