fix(测试跟踪): 测试计划报告针对没有正常结束的旧数据出现表格中通过率为空的情况进行优化

--bug=1024852 --user=宋天阳 【测试跟踪】github#23094,测试跟踪里面的历史接口自动化测试报告成功率都变成0了
https://www.tapd.cn/55049933/s/1355334
This commit is contained in:
song-tianyang 2023-03-23 22:23:19 +08:00 committed by fit2-zhao
parent 39aed27e92
commit 6a99adc589
2 changed files with 30 additions and 8 deletions

View File

@ -139,13 +139,29 @@ public class TestPlanReportService {
} catch (Exception e) {
LogUtil.error("格式化查询请求参数出错!", e);
}
return extTestPlanReportMapper.list(request);
/*
2.8之前的逻辑中会检查有没有查到成功率没查到的话重新计算
现在想来如果没查到就没查到 报告结束的时候会统计成功率 报告没结束也没必要查询成功率
在2.10之前这么处理没有问题时2.10将去掉这段注释
2.8之前的逻辑中会检查有没有查到成功率没查到的话重新计算 2.8之后成功率的计算和测试数据统计绑定在一起
以下是针对旧数据的处理如果存在已完成但0成功率为0的报告进行通过率的计算
*/
List<TestPlanReportDTO> testPlanReportDTOList = extTestPlanReportMapper.list(request);
for (TestPlanReportDTO testPlanReportDTO : testPlanReportDTOList) {
if (StringUtils.equalsAnyIgnoreCase(
testPlanReportDTO.getStatus(),
TestPlanReportStatus.FAILED.name(),
TestPlanReportStatus.COMPLETED.name(),
TestPlanReportStatus.SUCCESS.name())
&& (testPlanReportDTO.getPassRate() == null || testPlanReportDTO.getPassRate() == 0)) {
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportDTO.getId());
TestPlanReportContentWithBLOBs content = this.selectTestPlanReportContentByReportId(testPlanReportDTO.getId());
TestPlanReportDataStruct testPlanReportCountData
= testPlanService.buildTestPlanReportStructByTestPlanReport(testPlanReport, content);
if (testPlanReportCountData != null) {
testPlanReportDTO.setPassRate(testPlanReportCountData.getPassRate());
}
}
}
return testPlanReportDTOList;
}
}

View File

@ -155,10 +155,6 @@ public class TestPlanService {
@Resource
private ObjectMapper objectMapper;
@Resource
private TestResourcePoolMapper testResourcePoolMapper;
@Resource
private TestPlanReportMapper testPlanReportMapper;
@Resource
private ApiPoolDebugService apiPoolDebugService;
public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) {
@ -2085,4 +2081,14 @@ public class TestPlanService {
return projectIds.stream().distinct().collect(Collectors.toList());
}
public TestPlanReportDataStruct buildTestPlanReportStructByTestPlanReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContent) {
TestPlanWithBLOBs testPlanWithBLOBs = this.testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId());
TestPlanReportDataStruct testPlanReportDataStruct = new TestPlanReportDataStruct();
try {
testPlanReportDataStruct = this.buildTestPlanReportStruct(testPlanWithBLOBs, testPlanReport, testPlanReportContent);
} catch (Exception e) {
LoggerUtil.error("统计测试计划数据出错!", e);
}
return testPlanReportDataStruct;
}
}