fix: 测试用例导入功能测试不能选择自动方式

This commit is contained in:
chenjianxing 2020-08-05 10:55:21 +08:00
parent e1089b1eb1
commit 1faa4b6e8c
6 changed files with 62 additions and 6 deletions

View File

@ -1,5 +1,48 @@
package io.metersphere.commons.constants;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class TestCaseConstants {
public static final int MAX_NODE_DEPTH = 5;
public enum Type {
Functional("functional"), Performance("performance"), Aapi("api");
private String value;
Type(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
public static List<String> getValues() {
List<Type> types = Arrays.asList(Type.values());
return types.stream().map(Type::getValue).collect(Collectors.toList());
}
}
public enum Method {
Manual("manual"), Auto("auto");
private String value;
Method(String value) {
this.value = value;
}
public String getValue() {
return this.value;
}
public static List<String> getValues() {
List<Method> types = Arrays.asList(Method.values());
return types.stream().map(Method::getValue).collect(Collectors.toList());
}
}
}

View File

@ -41,16 +41,20 @@ public class TestCaseDataListener extends EasyExcelListener<TestCaseExcelData> {
String[] nodes = nodePath.split("/");
if (nodes.length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
stringBuilder.append(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"));
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level") + "; ");
}
for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
stringBuilder.append(Translator.get("module_not_null"));
stringBuilder.append(Translator.get("module_not_null") + "; ");
break;
}
}
}
if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) {
stringBuilder.append(Translator.get("functional_method_tip") + "; ");
}
if (!userIds.contains(data.getMaintainer())) {
stringBuilder.append(Translator.get("user_not_exists") + "" + data.getMaintainer() + "; ");
}

View File

@ -9,6 +9,7 @@ import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtTestCaseMapper;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.BeanUtils;
@ -309,8 +310,8 @@ public class TestCaseService {
private List<TestCaseExcelData> generateExportTemplate() {
List<TestCaseExcelData> list = new ArrayList<>();
StringBuilder path = new StringBuilder("");
List<String> types = Arrays.asList("functional", "performance", "api");
List<String> methods = Arrays.asList("manual", "auto");
List<String> types = TestCaseConstants.Type.getValues();
List<String> methods = TestCaseConstants.Method.getValues();
SessionUser user = SessionUtils.getUser();
for (int i = 1; i <= 5; i++) {
TestCaseExcelData data = new TestCaseExcelData();
@ -318,8 +319,13 @@ public class TestCaseService {
path.append("/" + Translator.get("module") + i);
data.setNodePath(path.toString());
data.setPriority("P" + i % 4);
data.setType(types.get(i % 3));
data.setMethod(methods.get(i % 2));
String type = types.get(i % 3);
data.setType(type);
if (StringUtils.equals(TestCaseConstants.Type.Functional.getValue(), type)) {
data.setMethod(TestCaseConstants.Method.Manual.getValue());
} else {
data.setMethod(methods.get(i % 2));
}
data.setPrerequisite(Translator.get("preconditions_optional"));
data.setStepDesc("1. " + Translator.get("step_tip_separate") +
"\n2. " + Translator.get("step_tip_order") + "\n3. " + Translator.get("step_tip_optional"));

View File

@ -117,6 +117,7 @@ plan_name_already_exists=Test plan name already exists
test_case_already_exists_excel=There are duplicate test cases in the import file
test_case_module_already_exists=The module name already exists at the same level
api_test_name_already_exists=Test name already exists
functional_method_tip=Functional test not support auto method
#ldap
ldap_url_is_null=LDAP address is empty

View File

@ -117,6 +117,7 @@ plan_name_already_exists=测试计划名称已存在
test_case_already_exists_excel=导入文件中存在重复用例
test_case_module_already_exists=同层级下已存在该模块名称
api_test_name_already_exists=测试名称已经存在
functional_method_tip=功能测试不支持自动方式
#ldap
ldap_url_is_null=LDAP地址为空

View File

@ -117,6 +117,7 @@ plan_name_already_exists=測試計劃名稱已存在
test_case_already_exists_excel=導入文件中存在重復用例
test_case_module_already_exists=同層級下已存在該模塊名稱
api_test_name_already_exists=測試名稱已經存在
functional_method_tip=功能測試不支持自動方式
#ldap
ldap_url_is_null=LDAP地址為空