fix(测试跟踪): 修复功能用例导入Excel步骤有问题

--user=郭雨琦 修复功能用例导入Excel步骤有问题
This commit is contained in:
guoyuqi 2022-02-18 19:04:27 +08:00 committed by jianxing
parent c9e87d73cd
commit 4a58792154
1 changed files with 8 additions and 16 deletions

View File

@ -521,11 +521,11 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
Set<Integer> rowNums = new HashSet<>(); Set<Integer> rowNums = new HashSet<>();
if (data.getStepDesc() != null) { if (data.getStepDesc() != null) {
String[] stepDesc = data.getStepDesc().split("\r\n"); String[] stepDesc = data.getStepDesc().split("\r|\n|\r\n");
int rowIndex = 1; int rowIndex = 1;
for (String row : stepDesc) { for (String row : stepDesc) {
TestCaseNoModelDataListener.RowInfo rowInfo = this.parseIndexInRow(row); TestCaseNoModelDataListener.RowInfo rowInfo = this.parseIndexInRow(row,rowIndex);
stepDescList.add(rowInfo.rowInfo); stepDescList.add(rowInfo.rowInfo);
rowNums.add(rowIndex++); rowNums.add(rowIndex++);
} }
@ -534,22 +534,14 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
} }
if (data.getStepResult() != null) { if (data.getStepResult() != null) {
String stepResult = data.getStepResult().replaceAll("\\n([0-9]+\\.)", "\r\n$1"); String[] stepRes = data.getStepResult().split("\r|\n|\r\n");
String[] stepRes = stepResult.split("\r\n");
int lastStepIndex = 1; int lastStepIndex = 1;
for (String row : stepRes) { for (String row : stepRes) {
TestCaseNoModelDataListener.RowInfo rowInfo = this.parseIndexInRow(row); TestCaseNoModelDataListener.RowInfo rowInfo = this.parseIndexInRow(row,lastStepIndex);
int rowIndex = rowInfo.index;
String rowMessage = rowInfo.rowInfo; String rowMessage = rowInfo.rowInfo;
stepResList.add(rowMessage);
if (rowIndex > -1 && rowNums.contains(rowIndex)) {
listUtils.set(stepResList, lastStepIndex - 1, rowMessage, "");
lastStepIndex = rowIndex;
} else {
listUtils.set(stepResList, lastStepIndex - 1, rowMessage, "");
lastStepIndex++; lastStepIndex++;
} }
}
} else { } else {
stepResList.add(""); stepResList.add("");
} }
@ -578,7 +570,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
return jsonArray.toJSONString(); return jsonArray.toJSONString();
} }
private RowInfo parseIndexInRow(String row) { private RowInfo parseIndexInRow(String row,int rowIndex) {
RowInfo rowInfo = new RowInfo(); RowInfo rowInfo = new RowInfo();
String parseString = row; String parseString = row;
int index = -1; int index = -1;
@ -592,7 +584,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
String[] rowSplit = StringUtils.split(parseString, splitChar); String[] rowSplit = StringUtils.split(parseString, splitChar);
if (rowSplit.length > 0) { if (rowSplit.length > 0) {
String indexString = rowSplit[0]; String indexString = rowSplit[0];
if (StringUtils.isNumeric(indexString)) { if (StringUtils.isNumeric(indexString)&&indexString.equals(String.valueOf(rowIndex))) {
try { try {
index = Integer.parseInt(indexString); index = Integer.parseInt(indexString);
rowMessage = StringUtils.substring(parseString, indexString.length() + splitChar.length()); rowMessage = StringUtils.substring(parseString, indexString.length() + splitChar.length());