fix(测试计划): 计划组报告执行状态有误

This commit is contained in:
song-cc-rock 2024-06-17 17:06:46 +08:00 committed by Craftsman
parent 18d44b6f92
commit 5b3a0040e2
2 changed files with 10 additions and 2 deletions

View File

@ -21,6 +21,7 @@
<select id="getGroupExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiCase"> <select id="getGroupExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiCase">
select tpac.id as testPlanApiCaseId, atc.id as apiCaseId, atc.num as apiCaseNum, atc.name as apiCaseName, atc.priority as apiCasePriority, select tpac.id as testPlanApiCaseId, atc.id as apiCaseId, atc.num as apiCaseNum, atc.name as apiCaseName, atc.priority as apiCasePriority,
tpac.test_plan_collection_id testPlanCollectionId, tpac.environment_id as environmentId,
if(ad.module_id = 'root','未规划用例', ad.module_id) as apiCaseModule, tpac.execute_user as apiCaseExecuteUser, if(ad.module_id = 'root','未规划用例', ad.module_id) as apiCaseModule, tpac.execute_user as apiCaseExecuteUser,
ifnull(tpac.last_exec_result, 'PENDING') as apiCaseExecuteResult, tpac.last_exec_report_id apiCaseExecuteReportId, tpac.pos pos ifnull(tpac.last_exec_result, 'PENDING') as apiCaseExecuteResult, tpac.last_exec_report_id apiCaseExecuteReportId, tpac.pos pos
from test_plan_api_case tpac join api_test_case atc on atc.id = tpac.api_case_id from test_plan_api_case tpac join api_test_case atc on atc.id = tpac.api_case_id

View File

@ -475,8 +475,15 @@ public class TestPlanReportService {
CaseCount summaryCount = JSON.parseObject(new String(reportSummary.getExecuteResult()), CaseCount.class); CaseCount summaryCount = JSON.parseObject(new String(reportSummary.getExecuteResult()), CaseCount.class);
planReport.setExecuteRate(RateCalculateUtils.divWithPrecision(((int) caseTotal - summaryCount.getPending()), (int) caseTotal, 2)); planReport.setExecuteRate(RateCalculateUtils.divWithPrecision(((int) caseTotal - summaryCount.getPending()), (int) caseTotal, 2));
planReport.setPassRate(RateCalculateUtils.divWithPrecision(summaryCount.getSuccess(), (int) caseTotal, 2)); planReport.setPassRate(RateCalculateUtils.divWithPrecision(summaryCount.getSuccess(), (int) caseTotal, 2));
if (planReport.getIntegrated()) {
// 计划组的(执行)结果状态: 子计划全部成功 ? 成功 : 失败
TestPlanReportExample reportExample = new TestPlanReportExample();
reportExample.createCriteria().andParentIdEqualTo(postParam.getReportId()).andIntegratedEqualTo(false).andResultStatusNotEqualTo(ReportStatus.SUCCESS.name());
planReport.setResultStatus(testPlanReportMapper.countByExample(reportExample) == 0 ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name());
} else {
// 计划的(执行)结果状态: 通过率 >= 阈值 ? 成功 : 失败 // 计划的(执行)结果状态: 通过率 >= 阈值 ? 成功 : 失败
planReport.setResultStatus(planReport.getPassRate() >= planReport.getPassThreshold() ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name()); planReport.setResultStatus(planReport.getPassRate() >= planReport.getPassThreshold() ? ReportStatus.SUCCESS.name() : ReportStatus.ERROR.name());
}
testPlanReportMapper.updateByPrimaryKeySelective(planReport); testPlanReportMapper.updateByPrimaryKeySelective(planReport);
} }