fix(测试跟踪): 修复测试用例导出时某些字段未导出的问题

This commit is contained in:
shiziyuan9527 2021-03-20 10:44:30 +08:00
parent 2c41d790eb
commit 78506f814f
7 changed files with 40 additions and 34 deletions

View File

@ -20,8 +20,8 @@ public class TestCaseExcelData {
private String priority; private String priority;
@ExcelIgnore @ExcelIgnore
private String tags; private String tags;
@ExcelIgnore // @ExcelIgnore
private String method; // private String method;
@ExcelIgnore @ExcelIgnore
private String prerequisite; private String prerequisite;
@ExcelIgnore @ExcelIgnore

View File

@ -45,10 +45,10 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
@Length(min = 0, max = 1000) @Length(min = 0, max = 1000)
private String tags; private String tags;
@NotBlank(message = "{cannot_be_null}") // @NotBlank(message = "{cannot_be_null}")
@ExcelProperty("测试方式") // @ExcelProperty("测试方式")
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}") // @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
private String method; // private String method;
@ColumnWidth(50) @ColumnWidth(50)
@ExcelProperty("前置条件") @ExcelProperty("前置条件")

View File

@ -45,10 +45,10 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
@Length(min = 0, max = 1000) @Length(min = 0, max = 1000)
private String tags; private String tags;
@NotBlank(message = "{cannot_be_null}") // @NotBlank(message = "{cannot_be_null}")
@ExcelProperty("測試方式") // @ExcelProperty("測試方式")
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}") // @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
private String method; // private String method;
@ColumnWidth(50) @ColumnWidth(50)
@ExcelProperty("前置條件") @ExcelProperty("前置條件")

View File

@ -46,10 +46,10 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
@Length(min = 0, max = 1000) @Length(min = 0, max = 1000)
private String tags; private String tags;
@NotBlank(message = "{cannot_be_null}") // @NotBlank(message = "{cannot_be_null}")
@ExcelProperty("Method") // @ExcelProperty("Method")
@Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}") // @Pattern(regexp = "(^manual$)|(^auto$)", message = "{test_case_method_validate}")
private String method; // private String method;
@ColumnWidth(50) @ColumnWidth(50)
@ExcelProperty("Prerequisite") @ExcelProperty("Prerequisite")

View File

@ -53,9 +53,9 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
} }
} }
if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) { // if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) {
stringBuilder.append(Translator.get("functional_method_tip") + "; "); // stringBuilder.append(Translator.get("functional_method_tip") + "; ");
} // }
if (!userIds.contains(data.getMaintainer())) { if (!userIds.contains(data.getMaintainer())) {
stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; "); stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; ");

View File

@ -131,8 +131,8 @@ public class TestCaseService {
.andNodePathEqualTo(testCase.getNodePath()) .andNodePathEqualTo(testCase.getNodePath())
.andTypeEqualTo(testCase.getType()) .andTypeEqualTo(testCase.getType())
.andMaintainerEqualTo(testCase.getMaintainer()) .andMaintainerEqualTo(testCase.getMaintainer())
.andPriorityEqualTo(testCase.getPriority()) .andPriorityEqualTo(testCase.getPriority());
.andMethodEqualTo(testCase.getMethod()); // .andMethodEqualTo(testCase.getMethod());
// if (StringUtils.isNotBlank(testCase.getNodeId())) { // if (StringUtils.isNotBlank(testCase.getNodeId())) {
// criteria.andNodeIdEqualTo(testCase.getTestId()); // criteria.andNodeIdEqualTo(testCase.getTestId());
@ -432,7 +432,7 @@ public class TestCaseService {
List<TestCaseExcelData> list = new ArrayList<>(); List<TestCaseExcelData> list = new ArrayList<>();
StringBuilder path = new StringBuilder(""); StringBuilder path = new StringBuilder("");
List<String> types = TestCaseConstants.Type.getValues(); List<String> types = TestCaseConstants.Type.getValues();
List<String> methods = TestCaseConstants.Method.getValues(); // List<String> methods = TestCaseConstants.Method.getValues();
SessionUser user = SessionUtils.getUser(); SessionUser user = SessionUtils.getUser();
for (int i = 1; i <= 5; i++) { for (int i = 1; i <= 5; i++) {
TestCaseExcelData data = new TestCaseExcelData(); TestCaseExcelData data = new TestCaseExcelData();
@ -442,11 +442,11 @@ public class TestCaseService {
data.setPriority("P" + i % 4); data.setPriority("P" + i % 4);
String type = types.get(i % 3); String type = types.get(i % 3);
data.setType(type); data.setType(type);
if (StringUtils.equals(TestCaseConstants.Type.Functional.getValue(), type)) { // if (StringUtils.equals(TestCaseConstants.Type.Functional.getValue(), type)) {
data.setMethod(TestCaseConstants.Method.Manual.getValue()); // data.setMethod(TestCaseConstants.Method.Manual.getValue());
} else { // } else {
data.setMethod(methods.get(i % 2)); // data.setMethod(methods.get(i % 2));
} // }
data.setPrerequisite(Translator.get("preconditions_optional")); data.setPrerequisite(Translator.get("preconditions_optional"));
data.setStepDesc("1. " + Translator.get("step_tip_separate") + data.setStepDesc("1. " + Translator.get("step_tip_separate") +
"\n2. " + Translator.get("step_tip_order") + "\n3. " + Translator.get("step_tip_optional")); "\n2. " + Translator.get("step_tip_order") + "\n3. " + Translator.get("step_tip_optional"));
@ -461,7 +461,7 @@ public class TestCaseService {
explain.setName(Translator.get("do_not_modify_header_order")); explain.setName(Translator.get("do_not_modify_header_order"));
explain.setNodePath(Translator.get("module_created_automatically")); explain.setNodePath(Translator.get("module_created_automatically"));
explain.setType(Translator.get("options") + "functional、performance、api"); explain.setType(Translator.get("options") + "functional、performance、api");
explain.setMethod(Translator.get("options") + "manual、auto"); // explain.setMethod(Translator.get("options") + "manual、auto");
explain.setPriority(Translator.get("options") + "P0、P1、P2、P3"); explain.setPriority(Translator.get("options") + "P0、P1、P2、P3");
explain.setMaintainer(Translator.get("please_input_workspace_member")); explain.setMaintainer(Translator.get("please_input_workspace_member"));
@ -483,7 +483,11 @@ public class TestCaseService {
private List<TestCaseExcelData> generateTestCaseExcel(TestCaseBatchRequest request) { private List<TestCaseExcelData> generateTestCaseExcel(TestCaseBatchRequest request) {
ServiceUtils.getSelectAllIds(request, request.getCondition(), ServiceUtils.getSelectAllIds(request, request.getCondition(),
(query) -> extTestCaseMapper.selectIds(query)); (query) -> extTestCaseMapper.selectIds(query));
List<OrderRequest> orderList = ServiceUtils.getDefaultOrder(request.getOrders()); QueryTestCaseRequest condition = request.getCondition();
List<OrderRequest> orderList = new ArrayList<>();
if (condition != null) {
orderList = ServiceUtils.getDefaultOrder(condition.getOrders());
}
OrderRequest order = new OrderRequest(); OrderRequest order = new OrderRequest();
order.setName("sort"); order.setName("sort");
order.setType("desc"); order.setType("desc");
@ -499,10 +503,10 @@ public class TestCaseService {
data.setNodePath(t.getNodePath()); data.setNodePath(t.getNodePath());
data.setPriority(t.getPriority()); data.setPriority(t.getPriority());
data.setType(t.getType()); data.setType(t.getType());
data.setMethod(t.getMethod()); // data.setMethod(t.getMethod());
data.setPrerequisite(t.getPrerequisite()); data.setPrerequisite(t.getPrerequisite());
data.setTags(t.getTags()); data.setTags(t.getTags());
if (t.getMethod().equals("manual")) { if (StringUtils.equals(t.getMethod(), "manual") || StringUtils.isBlank(t.getMethod())) {
String steps = t.getSteps(); String steps = t.getSteps();
String setp = ""; String setp = "";
setp = steps; setp = steps;
@ -530,19 +534,19 @@ public class TestCaseService {
result.setLength(0); result.setLength(0);
data.setRemark(t.getRemark()); data.setRemark(t.getRemark());
} else if (t.getMethod().equals("auto") && t.getType().equals("api")) { } else if ("auto".equals(t.getMethod()) && "api".equals(t.getType())) {
data.setStepDesc(""); data.setStepDesc("");
data.setStepResult(""); data.setStepResult("");
if (t.getTestId() != null && t.getTestId().equals("other")) { if (t.getTestId() != null && "other".equals(t.getTestId())) {
data.setRemark(t.getOtherTestName()); data.setRemark(t.getOtherTestName());
} else { } else {
data.setRemark("[" + t.getApiName() + "]" + "\n" + t.getRemark()); data.setRemark("[" + t.getApiName() + "]" + "\n" + t.getRemark());
} }
} else if (t.getMethod().equals("auto") && t.getType().equals("performance")) { } else if ("auto".equals(t.getMethod()) && "performance".equals(t.getType())) {
data.setStepDesc(""); data.setStepDesc("");
data.setStepResult(""); data.setStepResult("");
if (t.getTestId() != null && t.getTestId().equals("other")) { if (t.getTestId() != null && "other".equals(t.getTestId())) {
data.setRemark(t.getOtherTestName()); data.setRemark(t.getOtherTestName());
} else { } else {
data.setRemark(t.getPerformName()); data.setRemark(t.getPerformName());

View File

@ -161,4 +161,6 @@ UPDATE file_metadata JOIN (SELECT file_id, project_id
SET file_metadata.project_id = temp.project_id; SET file_metadata.project_id = temp.project_id;
-- add execution_times testPlan -- add execution_times testPlan
alter table test_plan alter table test_plan
add execution_times int null; add execution_times int null;
alter table test_case modify method varchar(15) null comment 'Test case method type';