diff --git a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java index e30a6720b3..a7c5943abd 100644 --- a/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java +++ b/test-track/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java @@ -481,7 +481,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener> getSingleRowSteps(String cellDesc, String cellResult, Integer startStepIndex) { List> steps = new ArrayList<>(); - List stepDescList = new ArrayList<>(); - List stepResList = new ArrayList<>(); - if (StringUtils.isNotEmpty(cellDesc)) { - // 根据[1], [2]...分割步骤描述, 开头空字符去掉, 末尾保留 - String[] stepDesc = cellDesc.split("\\[\\d+]", -1); - if (StringUtils.isEmpty(stepDesc[0])) { - stepDesc = Arrays.copyOfRange(stepDesc, 1, stepDesc.length); - } - - stepDescList.addAll(Arrays.asList(stepDesc)); - } else { - stepDescList.add(StringUtils.EMPTY); - } - - if (StringUtils.isNotEmpty(cellResult)) { - // 根据[1], [2]...分割步骤描述, 开头空字符去掉, 末尾保留 - String[] stepRes = cellResult.split("\\[\\d+]", -1); - if (StringUtils.isEmpty(stepRes[0])) { - stepRes = Arrays.copyOfRange(stepRes, 1, stepRes.length); - } - stepResList.addAll(Arrays.asList(stepRes)); - } else { - stepResList.add(StringUtils.EMPTY); - } + List stepDescList = parseStepCell(cellDesc); + List stepResList = parseStepCell(cellResult); int index = Math.max(stepDescList.size(), stepResList.size()); for (int i = 0; i < index; i++) { @@ -889,6 +867,29 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener parseStepCell(String cellContent) { + List cellStepContentList = new ArrayList<>(); + if (StringUtils.isNotEmpty(cellContent)) { + // 根据[1], [2]...分割步骤描述, 开头空字符去掉, 末尾保留 + String[] cellContentArr = cellContent.split("\\[\\d+]", -1); + if (StringUtils.isEmpty(cellContentArr[0])) { + cellContentArr = Arrays.copyOfRange(cellContentArr, 1, cellContentArr.length); + } + for (String stepContent : cellContentArr) { + cellStepContentList.add(stepContent.replaceAll("^\n*|\n*$", StringUtils.EMPTY)); + } + } else { + cellStepContentList.add(StringUtils.EMPTY); + } + return cellStepContentList; + } + class RowInfo { public int index; public String rowInfo;