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);