fix(接口测试): 测试计划执行异常数据处理

This commit is contained in:
fit2-zhao 2022-01-26 18:21:59 +08:00 committed by fit2-zhao
parent c0a96dfc9d
commit 837ee824d3
2 changed files with 9 additions and 11 deletions

View File

@ -119,7 +119,8 @@ public class ApiScenarioExecuteService {
LoggerUtil.info("Scenario run-执行脚本装载-开始针对所有执行场景进行环境检查");
apiScenarioEnvService.checkEnv(request, apiScenarios);
// 集合报告设置
if (request.getConfig() != null && StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString()) && StringUtils.isNotEmpty(request.getConfig().getReportName())) {
if (request.getConfig() != null && StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString())
&& StringUtils.isNotEmpty(request.getConfig().getReportName())) {
if (request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
request.setExecuteType(ExecuteType.Completed.name());
} else {
@ -159,7 +160,8 @@ public class ApiScenarioExecuteService {
responseDTOS.add(new MsExecResponseDTO(JSON.toJSONString(scenarioIds), serialReportId, request.getRunMode()));
// 增加并行集合报告
if (request.getConfig() != null && request.getConfig().getMode().equals(RunModeConstants.PARALLEL.toString())) {
apiScenarioReportStructureService.save(apiScenarios, serialReportId, request.getConfig() != null ? request.getConfig().getReportType() : null);
apiScenarioReportStructureService.save(apiScenarios, serialReportId, request.getConfig() != null
? request.getConfig().getReportType() : null);
}
}
// 开始执行
@ -278,16 +280,12 @@ public class ApiScenarioExecuteService {
executeQueue.put(report.getId(), runModeDataDTO);
} catch (Exception ex) {
scenarioIds.remove(scenario.getId());
if (StringUtils.equalsAny(request.getTriggerMode(), TriggerMode.BATCH.name(), TriggerMode.SCHEDULE.name())) {
executeQueue.remove(report.getId());
remakeReportService.remakeScenario(request.getRunMode(), testPlanScenarioId, scenario, report);
} else {
MSException.throwException(ex);
continue;
}
}
}
scenarioNames.append(scenario.getName()).append(",");
// 生成文档结构
if (request.getConfig() == null || !StringUtils.equals(request.getConfig().getReportType(), RunModeConstants.SET_REPORT.toString())) {
apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig() != null ? request.getConfig().getReportType() : null);
@ -323,8 +321,8 @@ public class ApiScenarioExecuteService {
runModeDataDTO.setReportId(report.getId());
executeQueue.put(report.getId(), runModeDataDTO);
} else {
// 生成报告和HashTree
try {
// 生成报告和HashTree
RunModeDataDTO runModeDataDTO = new RunModeDataDTO(report, item.getId());
if (request.getConfig() != null && !request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString())) {
HashTree hashTree = GenerateHashTreeUtil.generateHashTree(item, StringUtils.isNotEmpty(serialReportId) ? serialReportId + "-" + i : reportId, request.getConfig().getEnvMap(), request.getConfig().getReportType());

View File

@ -143,6 +143,6 @@ public class RemakeReportService {
apiScenarioMapper.updateByPrimaryKey(scenarioWithBLOBs);
}
report.setStatus(APITestStatus.Error.name());
apiScenarioReportMapper.insert(report);
apiScenarioReportMapper.updateByPrimaryKeySelective(report);
}
}