From 023bce329fb16ab3eb98aafd6f4aeb6cdeb36d63 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 27 Mar 2023 17:16:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=87=8D=E8=B7=91=E6=97=B6=E6=B2=A1=E6=9C=89=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E8=AE=A1=E7=AE=97=E6=8A=A5=E5=91=8A=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复测试计划失败重跑时没有重新计算报告内容的问题 Closes #23171 --- .../metersphere/plan/service/TestPlanReportService.java | 8 ++++---- .../java/io/metersphere/plan/service/TestPlanService.java | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 30232a9c2b..510408c5b8 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -620,7 +620,7 @@ public class TestPlanReportService { content.setApiBaseCount(null); } TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId()); - TestPlanReportDataStruct apiBaseCountStruct = this.generateTestPlanReportStruct(testPlan, testPlanReport, content); + TestPlanReportDataStruct apiBaseCountStruct = this.genReportStruct(testPlan, testPlanReport, content, isRerunningTestPlan); if (apiBaseCountStruct.getPassRate() == 1) { testPlanReport.setStatus(TestPlanReportStatus.SUCCESS.name()); } else if (apiBaseCountStruct.getPassRate() < 1) { @@ -675,11 +675,11 @@ public class TestPlanReportService { } //构建测试计划报告的数据结构 - private TestPlanReportDataStruct generateTestPlanReportStruct(TestPlanWithBLOBs testPlan, TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent) { + private TestPlanReportDataStruct genReportStruct(TestPlanWithBLOBs testPlan, TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs reportContent, boolean rebuildReport) { TestPlanReportDataStruct returnDTO = null; if (testPlanReport != null && reportContent != null) { try { - returnDTO = testPlanService.buildTestPlanReportStruct(testPlan, testPlanReport, reportContent); + returnDTO = testPlanService.buildReportStruct(testPlan, testPlanReport, reportContent, rebuildReport); //查找运行环境 this.initRunInformation(returnDTO, testPlanReport); } catch (Exception e) { @@ -1066,7 +1066,7 @@ public class TestPlanReportService { } if (this.isDynamicallyGenerateReports(testPlanReportContent) || StringUtils.isNotEmpty(testPlanReportContent.getApiBaseCount())) { TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId()); - testPlanReportDTO = this.generateTestPlanReportStruct(testPlan, testPlanReport, testPlanReportContent); + testPlanReportDTO = this.genReportStruct(testPlan, testPlanReport, testPlanReportContent, false); } testPlanReportDTO.setId(reportId); testPlanReportDTO.setName(testPlanReport.getName()); diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index d937d69f9e..9c7c065313 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -1383,7 +1383,7 @@ public class TestPlanService { * @param testPlanReportContentWithBLOBs 测试计划报告内容 * @return */ - public TestPlanReportDataStruct buildTestPlanReportStruct(TestPlanWithBLOBs testPlan, TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs) { + public TestPlanReportDataStruct buildReportStruct(TestPlanWithBLOBs testPlan, TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContentWithBLOBs, boolean rebuildReport) { TestPlanReportDataStruct testPlanReportStruct = null; if (ObjectUtils.allNotNull(testPlanReport, testPlanReportContentWithBLOBs)) { Map config = null; @@ -1392,7 +1392,7 @@ public class TestPlanService { } testPlanReportStruct = this.getTestPlanReportStructByCreated(testPlanReportContentWithBLOBs); //检查是否有已经生成过的测试计划报告内容。如若没有则进行动态计算 - if (testPlanReportStruct == null) { + if (rebuildReport || testPlanReportStruct == null) { //查询测试计划内的用例信息,然后进行测试计划报告的结果统计 TestPlanCaseReportResultDTO testPlanExecuteReportDTO = testPlanReportService.selectCaseDetailByTestPlanReport(config, testPlan.getId(), testPlanReportContentWithBLOBs); testPlanReportStruct = initTestPlanReportStructData( @@ -2112,7 +2112,7 @@ public class TestPlanService { TestPlanWithBLOBs testPlanWithBLOBs = this.testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId()); TestPlanReportDataStruct testPlanReportDataStruct = new TestPlanReportDataStruct(); try { - testPlanReportDataStruct = this.buildTestPlanReportStruct(testPlanWithBLOBs, testPlanReport, testPlanReportContent); + testPlanReportDataStruct = this.buildReportStruct(testPlanWithBLOBs, testPlanReport, testPlanReportContent, false); } catch (Exception e) { LoggerUtil.error("统计测试计划数据出错!", e); }