fix(测试计划): 修复测试用例导入时用例状态不回显的问题

修复测试用例导入时用例状态不回显的问题
This commit is contained in:
song-tianyang 2021-07-01 17:36:15 +08:00 committed by fit2-zhao
parent bb920216e9
commit 3bbd86f1d2
7 changed files with 152 additions and 6 deletions

View File

@ -37,6 +37,14 @@ public class TestCaseExcelData {
@ExcelIgnore
private String stepModel;
/**
* 责任人
* 用例状态
* 用例等级
*/
@ExcelIgnore
private String status;
public Set<String> getExcludeColumnFiledNames(boolean needNum){
Set<String> excludeColumnFiledNames = new HashSet<>();
if(!needNum){

View File

@ -70,6 +70,11 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
@ExcelProperty("预期结果")
private String stepResult;
@ColumnWidth(50)
@ExcelProperty("用例状态")
private String status;
@ColumnWidth(50)
@ExcelProperty("编辑模式")
@NotRequired

View File

@ -70,6 +70,10 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
@ExcelProperty("預期結果")
private String stepResult;
@ColumnWidth(50)
@ExcelProperty("用例狀態")
private String status;
@ColumnWidth(50)
@ExcelProperty("編輯模式")
@NotRequired

View File

@ -71,6 +71,10 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
@ExcelProperty("Step result")
private String stepResult;
@ColumnWidth(50)
@ExcelProperty("Case status")
private String status;
@ColumnWidth(50)
@ExcelProperty("Edit Model")
@NotRequired

View File

@ -257,6 +257,37 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
}
testCase.setNodePath(nodePath);
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){
caseStatusValue = "Underway";
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){
caseStatusValue = "Prepare";
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){
caseStatusValue = "Completed";
}
if(StringUtils.isNotEmpty(caseStatusValue)){
JSONObject statusObj = new JSONObject();
statusObj.put("id",UUID.randomUUID().toString());
statusObj.put("name","用例状态");
statusObj.put("value",caseStatusValue);
statusObj.put("customData",null);
customArr.add(statusObj);
}
if(StringUtils.isNotEmpty(data.getMaintainer())){
JSONObject obj = new JSONObject();
obj.put("id",UUID.randomUUID().toString());
obj.put("name","责任人");
obj.put("value",data.getMaintainer());
obj.put("customData",null);
customArr.add(obj);
}
if(customArr.size()>0){
testCase.setCustomFields(customArr.toString());
}
//将标签设置为前端可解析的格式
String modifiedTags = modifyTagPattern(data);
testCase.setTags(modifiedTags);
@ -297,6 +328,37 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener<TestCaseE
String steps = getSteps(data);
testCase.setSteps(steps);
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){
caseStatusValue = "Underway";
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){
caseStatusValue = "Prepare";
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){
caseStatusValue = "Completed";
}
if(StringUtils.isNotEmpty(caseStatusValue)){
JSONObject statusObj = new JSONObject();
statusObj.put("id",UUID.randomUUID().toString());
statusObj.put("name","用例状态");
statusObj.put("value",caseStatusValue);
statusObj.put("customData",null);
customArr.add(statusObj);
}
if(StringUtils.isNotEmpty(data.getMaintainer())){
JSONObject obj = new JSONObject();
obj.put("id",UUID.randomUUID().toString());
obj.put("name","责任人");
obj.put("value",data.getMaintainer());
obj.put("customData",null);
customArr.add(obj);
}
if(customArr.size()>0){
testCase.setCustomFields(customArr.toString());
}
//将标签设置为前端可解析的格式
String modifiedTags = modifyTagPattern(data);
testCase.setTags(modifiedTags);

View File

@ -272,6 +272,37 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
testCase.setTags(modifiedTags);
testCase.setType("functional");
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){
caseStatusValue = "Underway";
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){
caseStatusValue = "Prepare";
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){
caseStatusValue = "Completed";
}
if(StringUtils.isNotEmpty(caseStatusValue)){
JSONObject statusObj = new JSONObject();
statusObj.put("id",UUID.randomUUID().toString());
statusObj.put("name","用例状态");
statusObj.put("value",caseStatusValue);
statusObj.put("customData",null);
customArr.add(statusObj);
}
if(StringUtils.isNotEmpty(data.getMaintainer())){
JSONObject obj = new JSONObject();
obj.put("id",UUID.randomUUID().toString());
obj.put("name","责任人");
obj.put("value",data.getMaintainer());
obj.put("customData",null);
customArr.add(obj);
}
if(customArr.size()>0){
testCase.setCustomFields(customArr.toString());
}
if (StringUtils.isNotBlank(data.getStepModel())
&& StringUtils.equals(data.getStepModel(), TestCaseConstants.StepModel.TEXT.name())) {
testCase.setStepDescription(data.getStepDesc());
@ -308,6 +339,37 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
String steps = getSteps(data);
testCase.setSteps(steps);
JSONArray customArr = new JSONArray();
String caseStatusValue = "";
if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){
caseStatusValue = "Underway";
}else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){
caseStatusValue = "Prepare";
}else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){
caseStatusValue = "Completed";
}
if(StringUtils.isNotEmpty(caseStatusValue)){
JSONObject statusObj = new JSONObject();
statusObj.put("id",UUID.randomUUID().toString());
statusObj.put("name","用例状态");
statusObj.put("value",caseStatusValue);
statusObj.put("customData",null);
customArr.add(statusObj);
}
if(StringUtils.isNotEmpty(data.getMaintainer())){
JSONObject obj = new JSONObject();
obj.put("id",UUID.randomUUID().toString());
obj.put("name","责任人");
obj.put("value",data.getMaintainer());
obj.put("customData",null);
customArr.add(obj);
}
if(customArr.size()>0){
testCase.setCustomFields(customArr.toString());
}
//将标签设置为前端可解析的格式
String modifiedTags = modifyTagPattern(data);
testCase.setTags(modifiedTags);

View File

@ -242,13 +242,13 @@ public class TestCaseService {
// 如果上边字段全部相同去检查 remark steps
if (!CollectionUtils.isEmpty(caseList)) {
String caseRemark = testCase.getRemark();
String caseSteps = testCase.getSteps();
String casePrerequisite = testCase.getPrerequisite();
String caseRemark = testCase.getRemark() == null? "" : testCase.getRemark();
String caseSteps = testCase.getSteps() == null? "" : testCase.getSteps();
String casePrerequisite = testCase.getPrerequisite() == null? "" : testCase.getPrerequisite();
for (TestCaseWithBLOBs tc : caseList) {
String steps = tc.getSteps();
String remark = tc.getRemark();
String prerequisite = tc.getPrerequisite();
String steps = tc.getSteps() == null?"" : tc.getSteps();
String remark = tc.getRemark() == null?"" : tc.getRemark();
String prerequisite = tc.getPrerequisite() == null?"" : tc.getPrerequisite();
if (StringUtils.equals(steps, caseSteps) && StringUtils.equals(remark, caseRemark) && StringUtils.equals(prerequisite, casePrerequisite)) {
//MSException.throwException(Translator.get("test_case_already_exists"));
return tc;
@ -872,6 +872,7 @@ public class TestCaseService {
}
}
data.setMaintainer(t.getMaintainer());
data.setStatus(t.getStatus());
list.add(data);
});
return list;