fix(测试计划): 修复测试计划执行接口用例时无法记录执行信息的问题

--bug=1025805 --user=宋天阳
【测试跟踪】测试计划详情-批量执行CASE-串行-测试跟踪首页过去七天测试计划失败用例未统计数量
https://www.tapd.cn/55049933/s/1366563;--bug=1025806 --user=宋天阳
【测试跟踪】jenkins执行测试计划-串行-测试跟踪首页-过去七天测试计划失败用例统计-接口用例失败次数未统计
https://www.tapd.cn/55049933/s/1366632
This commit is contained in:
song-tianyang 2023-04-25 17:51:11 +08:00 committed by fit2-zhao
parent 9acdca8c57
commit 4b74b970b1
1 changed files with 7 additions and 6 deletions

View File

@ -7,6 +7,7 @@ import io.metersphere.base.mapper.*;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
import io.metersphere.base.mapper.plan.TestPlanApiCaseMapper;
import io.metersphere.base.mapper.plan.ext.ExtTestPlanApiCaseMapper;
import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.constants.CommonConstants;
import io.metersphere.commons.constants.NoticeConstants;
@ -63,6 +64,8 @@ public class ApiDefinitionExecResultService {
private ApiCaseExecutionInfoService apiCaseExecutionInfoService;
@Resource
private ExtApiTestCaseMapper extApiTestCaseMapper;
@Resource
private ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper;
/**
* API/CASE 重试结果保留一条
@ -322,12 +325,10 @@ public class ApiDefinitionExecResultService {
if (StringUtils.equalsAny(dto.getRunMode(), ApiRunMode.SCHEDULE_API_PLAN.name(), ApiRunMode.JENKINS_API_PLAN.name())) {
TestPlanApiCase apiCase = testPlanApiCaseMapper.selectByPrimaryKey(dto.getTestId());
if (apiCase != null) {
if (MapUtils.isNotEmpty(dto.getExtendedParameters()) && dto.getExtendedParameters().containsKey("projectId")) {
String projectId = dto.getExtendedParameters().get("projectId").toString();
ApiDefinition apiDefinition = extApiTestCaseMapper.selectApiBasicInfoByCaseId(apiCase.getId());
String version = apiDefinition == null ? "" : apiDefinition.getVersionId();
apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), reportResult.getStatus(), triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version);
}
String projectId = extTestPlanApiCaseMapper.selectProjectId(apiCase.getId());
ApiDefinition apiDefinition = extApiTestCaseMapper.selectApiBasicInfoByCaseId(apiCase.getId());
String version = apiDefinition == null ? "" : apiDefinition.getVersionId();
apiCaseExecutionInfoService.insertExecutionInfo(apiCase.getId(), reportResult.getStatus(), triggerMode, projectId, ExecutionExecuteTypeEnum.TEST_PLAN.name(), version);
apiCase.setStatus(reportResult.getStatus());
apiCase.setUpdateTime(System.currentTimeMillis());
testPlanApiCaseMapper.updateByPrimaryKeySelective(apiCase);