diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 5bb62cd93c..c5f0ad1cb0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -111,7 +111,7 @@ public class ElementUtil { } } - public static void addCounter(HashTree tree, List variables) { + public static void addCounter(HashTree tree, List variables, boolean isInternal) { if (CollectionUtils.isNotEmpty(variables)) { List list = variables.stream().filter(ScenarioVariable::isCounterValid).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { @@ -121,7 +121,11 @@ public class ElementUtil { counterConfig.setProperty(TestElement.TEST_CLASS, CounterConfig.class.getName()); counterConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CounterConfigGui")); counterConfig.setName(item.getName()); - counterConfig.setStart(item.getStartNumber()); + if (isInternal) { + counterConfig.setStart((item.getStartNumber() + 1)); + } else { + counterConfig.setStart(item.getStartNumber()); + } counterConfig.setEnd(item.getEndNumber()); counterConfig.setVarName(item.getName()); counterConfig.setIncrement(item.getIncrement()); 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 3da52f26a7..40e34da394 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 @@ -162,7 +162,7 @@ public class MsScenario extends MsTestElement { tree.add(ParameterConfig.valueSupposeMock(arguments)); } ElementUtil.addCsvDataSet(tree, variables, config, "shareMode.group"); - ElementUtil.addCounter(tree, variables); + ElementUtil.addCounter(tree, variables, false); ElementUtil.addRandom(tree, variables); if (CollectionUtils.isNotEmpty(this.headers)) { config.setHeaders(this.headers); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index fc84a96da2..98a497b71c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -60,7 +60,7 @@ public class MsLoopController extends MsTestElement { final HashTree groupTree = controller(tree); if (CollectionUtils.isNotEmpty(config.getVariables())) { ElementUtil.addCsvDataSet(groupTree, config.getVariables(), config, "shareMode.thread"); - ElementUtil.addCounter(groupTree, config.getVariables()); + ElementUtil.addCounter(groupTree, config.getVariables(), true); ElementUtil.addRandom(groupTree, config.getVariables()); }