refactor(接口测试): 测试计划接口用例执行,资源池异常提示优化
--bug=1049011 --user=陈建星 【测试计划】计划详情-测试点资源池无效-场景列表-操作-执行场景用例失败 https://www.tapd.cn/55049933/s/1631376
This commit is contained in:
parent
e2b5f9a402
commit
98714c6cb2
|
@ -220,6 +220,24 @@ public class ApiExecuteService {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试计划资源,发送执行任务
|
||||
*
|
||||
* @param taskRequest 执行参数
|
||||
*/
|
||||
public TaskRequestDTO executePlanResource(TaskRequestDTO taskRequest) {
|
||||
try {
|
||||
return execute(taskRequest);
|
||||
} catch (MSException e) {
|
||||
if (e.getErrorCode() == ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG) {
|
||||
// 提示没有可用资源池
|
||||
throw new MSException(ApiResultCode.TASK_ERROR_MESSAGE_INVALID_RESOURCE_POOL);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送执行任务
|
||||
*
|
||||
|
@ -804,6 +822,7 @@ public class ApiExecuteService {
|
|||
if (testResourcePool == null ||
|
||||
// 资源池禁用
|
||||
!testResourcePool.getEnable() ||
|
||||
testResourcePool.getDeleted() ||
|
||||
// 项目没有资源池权限
|
||||
!commonProjectService.validateProjectResourcePool(testResourcePool, projectId)) {
|
||||
throw new MSException(ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG);
|
||||
|
|
|
@ -801,7 +801,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService {
|
|||
taskInfo.setRealTime(true);
|
||||
}
|
||||
|
||||
return apiExecuteService.execute(taskRequest);
|
||||
return apiExecuteService.executePlanResource(taskRequest);
|
||||
}
|
||||
|
||||
public void runRun(ExecTask execTask, ExecTaskItem execTaskItem, String userId) {
|
||||
|
|
|
@ -395,7 +395,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService {
|
|||
apiScenarioRunService.initApiScenarioReport(taskItem.getId(), apiScenario, scenarioReport);
|
||||
}
|
||||
|
||||
return apiExecuteService.execute(taskRequest);
|
||||
return apiExecuteService.executePlanResource(taskRequest);
|
||||
}
|
||||
|
||||
public void runRun(ExecTask execTask, ExecTaskItem execTaskItem, String userId) {
|
||||
|
|
|
@ -366,7 +366,8 @@ public class TestPlanApiCaseControllerTests extends BaseTest {
|
|||
public static void assertRun(MvcResult mvcResult) throws UnsupportedEncodingException {
|
||||
Map resultData = JSON.parseMap(mvcResult.getResponse().getContentAsString());
|
||||
Integer code = (Integer) resultData.get("code");
|
||||
if (code != ApiResultCode.RESOURCE_POOL_EXECUTE_ERROR.getCode() && code != ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG.getCode()) {
|
||||
if (code != ApiResultCode.RESOURCE_POOL_EXECUTE_ERROR.getCode() && code != ApiResultCode.EXECUTE_RESOURCE_POOL_NOT_CONFIG.getCode()
|
||||
&& code != ApiResultCode.TASK_ERROR_MESSAGE_INVALID_RESOURCE_POOL.getCode()) {
|
||||
Assertions.assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue