feat(测试计划): 补充更新用例表状态逻辑

This commit is contained in:
WangXu10 2024-05-16 15:14:53 +08:00 committed by 刘瑞斌
parent 593554a6a1
commit 1d3331f5ff
1 changed files with 25 additions and 0 deletions

View File

@ -386,6 +386,10 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
functionalCase.setId(request.getId());
testPlanFunctionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
//更新用例表执行状态
updateFunctionalCaseStatus(Arrays.asList(request.getCaseId()), request.getLastExecResult());
//执行记录
TestPlanCaseExecuteHistory executeHistory = buildHistory(request, logInsertModule.getOperator());
testPlanCaseExecuteHistoryMapper.insert(executeHistory);
@ -396,6 +400,25 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
operationLogService.batchAdd(logDTOList);
}
/**
* 更新功能用例表的执行状态
*
* @param ids
* @param lastExecResult
*/
private void updateFunctionalCaseStatus(List<String> ids, String lastExecResult) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseMapper functionalCaseMapper = sqlSession.getMapper(FunctionalCaseMapper.class);
ids.forEach(id -> {
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setId(id);
functionalCase.setLastExecuteResult(lastExecResult);
functionalCaseMapper.updateByPrimaryKeySelective(functionalCase);
});
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
}
private TestPlanCaseExecuteHistory buildHistory(TestPlanCaseRunRequest request, String operator) {
TestPlanCaseExecuteHistory executeHistory = new TestPlanCaseExecuteHistory();
@ -444,6 +467,8 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService {
List<TestPlanCaseExecuteHistory> historyList = getExecHistory(ids, request, logInsertModule, idsMap);
testPlanCaseExecuteHistoryMapper.batchInsert(historyList);
updateFunctionalCaseStatus(caseIds, request.getLastExecResult());
List<LogDTO> logDTOList = runLog(idsMap, caseIds, request.getProjectId(), organizationId, new ResourceLogInsertModule(TestPlanResourceConstants.RESOURCE_FUNCTIONAL_CASE, logInsertModule));
operationLogService.batchAdd(logDTOList);
}