fix(用例管理): 场景列表变量按逗号分隔,支持逗号转义

--bug=1045007 --user=陈建星 github #32177 支持用户在","前加"\"以区分分隔符 https://www.tapd.cn/55049933/s/1580890
This commit is contained in:
AgAngle 2024-09-19 14:01:30 +08:00 committed by Craftsman
parent 8e86034849
commit e3417dd9d9
1 changed files with 2 additions and 1 deletions

View File

@ -49,7 +49,8 @@ public class JmeterTestElementParserHelper {
public static UserParameters getUserParameters(List<CommonVariables> constantVariables, List<CommonVariables> listVariables) { public static UserParameters getUserParameters(List<CommonVariables> constantVariables, List<CommonVariables> listVariables) {
List<CommonVariables> variableResults = new ArrayList<>(); List<CommonVariables> variableResults = new ArrayList<>();
listVariables.forEach(listVariable -> { listVariables.forEach(listVariable -> {
String[] arrays = listVariable.getValue().replaceAll("[\r\n]", "").split(","); // ',' 分割但是支持 \, 转义
String[] arrays = listVariable.getValue().replaceAll("[\r\n]", "").split("(?<!\\\\),");
for (int i = 0; i < arrays.length; i++) { for (int i = 0; i < arrays.length; i++) {
CommonVariables commonVariables = BeanUtils.copyBean(new CommonVariables(), listVariable); CommonVariables commonVariables = BeanUtils.copyBean(new CommonVariables(), listVariable);
commonVariables.setKey(listVariable.getKey() + "_" + (i + 1)); commonVariables.setKey(listVariable.getKey() + "_" + (i + 1));