feat(测试计划报告): 修复测试计划报告内案例执行状态未得到更新的问题

--bug=1008171 --user=宋天阳 【测试计划】-执行定时任务后报告中接口+场景和性能用例执行状态未更新
https://www.tapd.cn/55049933/s/1071846
This commit is contained in:
song-tianyang 2021-11-22 14:42:39 +08:00 committed by 刘瑞斌
parent 6d09f39f99
commit 59f61557e3
1 changed files with 38 additions and 0 deletions

View File

@ -63,6 +63,8 @@ public class TestPlanReportService {
@Resource
TestPlanReportMapper testPlanReportMapper;
@Resource
ApiScenarioReportMapper apiScenarioReportMapper;
@Resource
TestPlanReportDataMapper testPlanReportDataMapper;
@Resource
ExtTestPlanScenarioCaseMapper extTestPlanScenarioCaseMapper;
@ -1118,6 +1120,8 @@ public class TestPlanReportService {
return null;
}
TestPlanReportContentWithBLOBs testPlanReportContent = testPlanReportContents.get(0);
//更新测试报告对应的最后执行结果
this.updateReportExecResult(testPlanReportContent);
TestPlanSimpleReportDTO testPlanReportDTO = new TestPlanSimpleReportDTO();
BeanUtils.copyBean(testPlanReportDTO, testPlanReportContent);
if (StringUtils.isNotBlank(testPlanReportContent.getFunctionResult())) {
@ -1162,6 +1166,40 @@ public class TestPlanReportService {
return testPlanReportDTO;
}
private void updateReportExecResult(TestPlanReportContentWithBLOBs testPlanReportContent) {
boolean isUpdate = false;
if (StringUtils.isNotBlank(testPlanReportContent.getScenarioAllCases())) {
List<TestPlanFailureScenarioDTO> allCases = JSONObject.parseArray(testPlanReportContent.getScenarioAllCases(), TestPlanFailureScenarioDTO.class);
for (TestPlanFailureScenarioDTO dto : allCases) {
if (StringUtils.equalsIgnoreCase(dto.getLastResult(), "Underway")) {
isUpdate = true;
ApiScenarioReport apiReport = apiScenarioReportMapper.selectByPrimaryKey(dto.getReportId());
if (apiReport != null) {
dto.setLastResult(apiReport.getStatus());
}
}
}
testPlanReportContent.setScenarioAllCases(JSONArray.toJSONString(allCases));
}
if (StringUtils.isNotBlank(testPlanReportContent.getLoadAllCases())) {
List<TestPlanLoadCaseDTO> allCases = JSONObject.parseArray(testPlanReportContent.getLoadAllCases(), TestPlanLoadCaseDTO.class);
for (TestPlanLoadCaseDTO dto : allCases) {
if (StringUtils.equalsIgnoreCase(dto.getStatus(), "run")) {
isUpdate = true;
LoadTestReport report = loadTestReportMapper.selectByPrimaryKey(dto.getReportId());
if (report != null) {
dto.setStatus(report.getStatus());
}
}
}
testPlanReportContent.setLoadAllCases(JSONArray.toJSONString(allCases));
}
if (isUpdate) {
testPlanReportContentMapper.updateByPrimaryKeyWithBLOBs(testPlanReportContent);
}
}
public void finishReport(TestPlanReport testPlanReport) {
long endTime = System.currentTimeMillis();
testPlanReport.setEndTime(endTime);