fix: 用例导入导出支持步骤编辑模式
This commit is contained in:
parent
14468c6dd1
commit
12f28344d0
|
@ -45,4 +45,8 @@ public class TestCaseConstants {
|
|||
return types.stream().map(Method::getValue).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
public enum StepModel {
|
||||
TEXT, STEP
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,6 @@ public class TestCaseExcelData {
|
|||
private String stepDesc;
|
||||
@ExcelIgnore
|
||||
private String stepResult;
|
||||
}
|
||||
@ExcelIgnore
|
||||
private String stepModel;
|
||||
}
|
||||
|
|
|
@ -69,4 +69,10 @@ public class TestCaseExcelDataCn extends TestCaseExcelData {
|
|||
@ColumnWidth(50)
|
||||
@ExcelProperty("预期结果")
|
||||
private String stepResult;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("编辑模式")
|
||||
@NotRequired
|
||||
@Pattern(regexp = "(^TEXT$)|(^STEP$)", message = "{test_case_step_model_validate}")
|
||||
private String stepModel;
|
||||
}
|
||||
|
|
|
@ -69,4 +69,10 @@ public class TestCaseExcelDataTw extends TestCaseExcelData {
|
|||
@ColumnWidth(50)
|
||||
@ExcelProperty("預期結果")
|
||||
private String stepResult;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("編輯模式")
|
||||
@NotRequired
|
||||
@Pattern(regexp = "(^TEXT$)|(^STEP$)", message = "{test_case_step_model_validate}")
|
||||
private String stepModel;
|
||||
}
|
||||
|
|
|
@ -70,4 +70,10 @@ public class TestCaseExcelDataUs extends TestCaseExcelData {
|
|||
@ColumnWidth(50)
|
||||
@ExcelProperty("Step result")
|
||||
private String stepResult;
|
||||
|
||||
@ColumnWidth(50)
|
||||
@ExcelProperty("Edit Model")
|
||||
@NotRequired
|
||||
@Pattern(regexp = "(^TEXT$)|(^STEP$)", message = "{test_case_step_model_validate}")
|
||||
private String stepModel;
|
||||
}
|
||||
|
|
|
@ -198,9 +198,14 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
|
|||
String modifiedTags = modifyTagPattern(data);
|
||||
testCase.setTags(modifiedTags);
|
||||
|
||||
String steps = getSteps(data);
|
||||
testCase.setSteps(steps);
|
||||
|
||||
if (StringUtils.isNotBlank(data.getStepModel())
|
||||
&& StringUtils.equals(data.getStepModel(), TestCaseConstants.StepModel.TEXT.name())) {
|
||||
testCase.setStepDescription(data.getStepDesc());
|
||||
testCase.setExpectedResult(data.getStepResult());
|
||||
} else {
|
||||
String steps = getSteps(data);
|
||||
testCase.setSteps(steps);
|
||||
}
|
||||
return testCase;
|
||||
}
|
||||
|
||||
|
|
|
@ -667,38 +667,49 @@ public class TestCaseService {
|
|||
data.setNodePath(t.getNodePath());
|
||||
data.setPriority(t.getPriority());
|
||||
data.setType(t.getType());
|
||||
if (StringUtils.isBlank(t.getStepModel())) {
|
||||
data.setStepModel(TestCaseConstants.StepModel.STEP.name());
|
||||
} else {
|
||||
data.setStepModel(t.getStepModel());
|
||||
}
|
||||
// data.setMethod(t.getMethod());
|
||||
data.setPrerequisite(t.getPrerequisite());
|
||||
data.setTags(t.getTags());
|
||||
if (StringUtils.equals(t.getMethod(), "manual") || StringUtils.isBlank(t.getMethod())) {
|
||||
String steps = t.getSteps();
|
||||
String setp = "";
|
||||
setp = steps;
|
||||
JSONArray jsonArray = null;
|
||||
|
||||
//解决旧版本保存用例导出报错
|
||||
try {
|
||||
jsonArray = JSON.parseArray(setp);
|
||||
} catch (Exception e) {
|
||||
if (steps.contains("null") && !steps.contains("\"null\"")) {
|
||||
setp = steps.replace("null", "\"\"");
|
||||
if (StringUtils.equals(data.getStepModel(), TestCaseConstants.StepModel.TEXT.name())) {
|
||||
data.setStepDesc(t.getStepDescription());
|
||||
data.setStepResult(t.getExpectedResult());
|
||||
} else {
|
||||
String steps = t.getSteps();
|
||||
String setp = "";
|
||||
setp = steps;
|
||||
JSONArray jsonArray = null;
|
||||
|
||||
//解决旧版本保存用例导出报错
|
||||
try {
|
||||
jsonArray = JSON.parseArray(setp);
|
||||
} catch (Exception e) {
|
||||
if (steps.contains("null") && !steps.contains("\"null\"")) {
|
||||
setp = steps.replace("null", "\"\"");
|
||||
jsonArray = JSON.parseArray(setp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(jsonArray)) {
|
||||
for (int j = 0; j < jsonArray.size(); j++) {
|
||||
int num = j + 1;
|
||||
step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\r\n");
|
||||
result.append(num + "." + jsonArray.getJSONObject(j).getString("result") + "\r\n");
|
||||
if (CollectionUtils.isNotEmpty(jsonArray)) {
|
||||
for (int j = 0; j < jsonArray.size(); j++) {
|
||||
int num = j + 1;
|
||||
step.append(num + "." + jsonArray.getJSONObject(j).getString("desc") + "\r\n");
|
||||
result.append(num + "." + jsonArray.getJSONObject(j).getString("result") + "\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.setStepDesc(step.toString());
|
||||
data.setStepResult(result.toString());
|
||||
step.setLength(0);
|
||||
result.setLength(0);
|
||||
data.setStepDesc(step.toString());
|
||||
data.setStepResult(result.toString());
|
||||
step.setLength(0);
|
||||
result.setLength(0);
|
||||
}
|
||||
data.setRemark(t.getRemark());
|
||||
|
||||
} else if ("auto".equals(t.getMethod()) && "api".equals(t.getType())) {
|
||||
|
|
|
@ -99,6 +99,7 @@ node_deep_limit=The node depth does not exceed 8 layers!
|
|||
before_delete_plan=There is an associated test case under this plan, please unlink it first!
|
||||
incorrect_format=\tincorrect format
|
||||
test_case_type_validate=\tmust be functional, performance, api
|
||||
test_case_step_model_validate=\tmust be TEXT, STEP
|
||||
test_case_priority_validate=\tmust be P0, P1, P2, P3
|
||||
test_case_method_validate=\tmust be manual, auto
|
||||
test_case_name=Name
|
||||
|
@ -218,4 +219,4 @@ authsource_configuration_is_null=Authentication source configuration cannot be e
|
|||
mobile_phone_number_cannot_be_empty=When the receiving mode is pin and enterprise wechat: the user's mobile phone number cannot be empty
|
||||
custom_field_already=A feild already exists under this workspace:
|
||||
template_already=A template already exists under this workspace:
|
||||
expect_name_exists=Expect name is exists
|
||||
expect_name_exists=Expect name is exists
|
||||
|
|
|
@ -99,6 +99,7 @@ node_deep_limit=节点深度不超过8层!
|
|||
before_delete_plan=该计划下存在关联测试用例,请先取消关联!
|
||||
incorrect_format=格式错误
|
||||
test_case_type_validate=必须为functional、performance、api
|
||||
test_case_step_model_validate=必须为TEXT、STEP
|
||||
test_case_priority_validate=必须为P0、P1、P2、P3
|
||||
test_case_method_validate=必须为manual、auto
|
||||
test_case_name=用例名称
|
||||
|
@ -218,4 +219,4 @@ authsource_name_is_null=认证源名称不能为空
|
|||
authsource_configuration_is_null=认证源配置不能为空
|
||||
custom_field_already=工作空间下已存在该字段:
|
||||
template_already=工作空间下已存在该模板:
|
||||
expect_name_exists=预期名称已存在
|
||||
expect_name_exists=预期名称已存在
|
||||
|
|
|
@ -99,6 +99,7 @@ node_deep_limit=節點深度不超過8層!
|
|||
before_delete_plan=該計劃下存在關聯測試用例,請先取消關聯!
|
||||
incorrect_format=格式錯誤
|
||||
test_case_type_validate=必須為functional、performance、api
|
||||
test_case_step_model_validate=必須為TEXT、STEP
|
||||
test_case_priority_validate=必須為P0、P1、P2、P3
|
||||
test_case_method_validate=必須為manual、auto
|
||||
test_case_name=用例名稱
|
||||
|
@ -219,4 +220,4 @@ authsource_name_is_null=認證源名稱不能為空
|
|||
authsource_configuration_is_null=認證源配置不能為空
|
||||
custom_field_already=工作空間下已存在該字段:
|
||||
template_already=工作空間下已存在該模板:
|
||||
expect_name_exists=預期名稱已存在
|
||||
expect_name_exists=預期名稱已存在
|
||||
|
|
Loading…
Reference in New Issue