fix(接口测试): 修复批量执行case部分case未选择运行环境批量执行未提醒选择环境的缺陷

--bug=1010862 --user=王孝刚
【接口测试】-批量执行case-部分case未选择运行环境-批量执行也未统一选择运行环境-可批量执行
https://www.tapd.cn/55049933/s/1120823
This commit is contained in:
wxg0103 2022-03-18 12:41:05 +08:00 committed by fit2-zhao
parent ddfc878024
commit fe30cc441c
1 changed files with 17 additions and 18 deletions

View File

@ -140,23 +140,19 @@ public class ApiCaseExecuteService {
if (CollectionUtils.isNotEmpty(caseList)) {
StringBuilder builderHttp = new StringBuilder();
StringBuilder builderTcp = new StringBuilder();
for (ApiTestCaseWithBLOBs apiCase : caseList) {
for (int i = caseList.size() - 1; i >= 0; i--) {
ApiTestCaseWithBLOBs apiCase = caseList.get(i);
JSONObject apiCaseNew = new JSONObject(apiCase.getRequest());
if ("HTTPSamplerProxy".equals(apiCaseNew.getString("type"))) {
try {
String environmentId = apiCaseNew.getString("useEnvironment");
if (!StringUtils.isNotEmpty(environmentId)) {
builderHttp.append(apiCase.getName()).append("; ");
}
} catch (Exception e) {
MSException.throwException("用例:" + builderHttp.append(apiCase.getName()).append("; ") + "运行环境为空!请检查");
if (apiCaseNew.has("type") && "HTTPSamplerProxy".equals(apiCaseNew.getString("type"))) {
if (!apiCaseNew.has("useEnvironment") || StringUtils.isEmpty(apiCaseNew.getString("useEnvironment"))) {
builderHttp.append(apiCase.getName()).append("; ");
}
}
if ("JDBCSampler".equals(apiCaseNew.getString("type"))) {
try {
if (apiCaseNew.has("type") && "JDBCSampler".equals(apiCaseNew.getString("type"))) {
DatabaseConfig dataSource = null;
if (apiCaseNew.has("useEnvironment") && apiCaseNew.has("dataSourceId")) {
String environmentId = apiCaseNew.getString("useEnvironment");
String dataSourceId = apiCaseNew.getString("dataSourceId");
DatabaseConfig dataSource = null;
ApiTestEnvironmentService environmentService = CommonBeanFactory.getBean(ApiTestEnvironmentService.class);
ApiTestEnvironmentWithBLOBs environment = environmentService.get(environmentId);
EnvironmentConfig envConfig = null;
@ -170,17 +166,20 @@ public class ApiCaseExecuteService {
}
}
}
if (dataSource == null) {
MSException.throwException("用例:" + builderTcp.append(apiCase.getName()).append("; "));
}
} catch (Exception e) {
MSException.throwException("用例数据源为空,请检查!");
}
if (dataSource == null) {
builderTcp.append(apiCase.getName()).append("; ");
}
}
}
if (StringUtils.isNotEmpty(builderHttp)) {
MSException.throwException("用例:" + builderHttp + "运行环境为空!请检查");
}
if (StringUtils.isNotEmpty(builderTcp)) {
MSException.throwException("用例:" + builderTcp + "数据源为空!请检查");
}
}
}
/**
* 接口定义case执行
*