From 3b5f985b19f7079d1f10b4032fefc03bfd0db78f Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 27 Oct 2021 16:09:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20#1?= =?UTF-8?q?007045=20#1007208=20=E3=80=90=E6=B5=8B=E8=AF=95=E8=B7=9F?= =?UTF-8?q?=E8=B8=AA=E3=80=91=E6=89=A7=E8=A1=8C=E6=95=B4=E4=B8=AA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=A1=E5=88=92=EF=BC=8C=E6=B2=A1=E6=9C=89=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E6=8E=A5=E5=8F=A3=E7=94=A8=E4=BE=8B=EF=BC=9B=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=8B=E5=8A=A8=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=AE=8C=EF=BC=8C=E7=8A=B6=E6=80=81=E8=BF=98=E6=98=AF=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1007045 --user=宋天阳 【测试跟踪】执行整个测试计划,没有执行接口用例 https://www.tapd.cn/55049933/s/1059874;--bug=1007208 --user=宋天阳 【测试跟踪】测试计划手动执行完,状态还是进行中 https://www.tapd.cn/55049933/s/1059875 --- .../base/mapper/ext/ExtTestPlanMapper.java | 2 + .../base/mapper/ext/ExtTestPlanMapper.xml | 6 ++- .../track/service/TestPlanReportService.java | 3 +- .../track/service/TestPlanService.java | 38 +++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java index db1adf8ac2..4b1df6a573 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.java @@ -35,4 +35,6 @@ public interface ExtTestPlanMapper { List findIdByPerformanceReportId(String reportId); List listRecent(@Param("userId") String userId, @Param("projectId") String currentProjectId); + + int updateActualEndTimeIsNullById(String testPlanID); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml index bc2bff3b90..2c567160ec 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanMapper.xml @@ -279,5 +279,9 @@ order by test_plan.update_time desc - + + update test_plan + set actual_end_time = null + where id = #{0} + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 62b716396d..d9b5754079 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -805,8 +805,9 @@ public class TestPlanReportService { //更新TestPlan状态为完成 TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(report.getTestPlanId()); if (testPlan != null) { + testPlanService.checkStatus(testPlan); // testPlan.setStatus(TestPlanStatus.Completed.name()); - testPlanMapper.updateByPrimaryKeySelective(testPlan); +// testPlanMapper.updateByPrimaryKeySelective(testPlan); } if (testPlan != null && StringUtils.equalsAny(report.getTriggerMode(), ReportTriggerMode.MANUAL.name(), diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 2a05480071..d02709bced 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -509,6 +509,43 @@ public class TestPlanService { } } + public void checkStatus(TestPlanWithBLOBs testPlanWithBLOBs) { // 检查执行结果,自动更新计划状态 + List statusList = new ArrayList<>(); + statusList.addAll(extTestPlanTestCaseMapper.getExecResultByPlanId(testPlanWithBLOBs.getId())); + statusList.addAll(testPlanApiCaseService.getExecResultByPlanId(testPlanWithBLOBs.getId())); + statusList.addAll(testPlanScenarioCaseService.getExecResultByPlanId(testPlanWithBLOBs.getId())); + statusList.addAll(testPlanLoadCaseService.getStatus(testPlanWithBLOBs.getId())); + if (statusList.size() == 0) { // 原先status不是prepare, 但删除所有关联用例的情况 + testPlanWithBLOBs.setStatus(TestPlanStatus.Prepare.name()); + editTestPlan(testPlanWithBLOBs); + return; + } + int passNum = 0, prepareNum = 0, failNum = 0; + for (String res : statusList) { + if (StringUtils.equals(res, TestPlanTestCaseStatus.Pass.name()) + || StringUtils.equals(res, "success") + || StringUtils.equals(res, ScenarioStatus.Success.name())) { + passNum++; + } else if (res == null || StringUtils.equals(TestPlanStatus.Prepare.name(), res)) { + prepareNum++; + } else { + failNum++; + } + } + if (passNum == statusList.size()) { // 全部通过 + testPlanWithBLOBs.setStatus(TestPlanStatus.Completed.name()); + this.editTestPlan(testPlanWithBLOBs); + // 发送成功通知 +// sendCompletedNotice(testPlanWithBLOBs); + } else if (prepareNum == 0 && passNum + failNum == statusList.size()) { // 已结束 + testPlanWithBLOBs.setStatus(TestPlanStatus.Finished.name()); + editTestPlan(testPlanWithBLOBs); + } else if (prepareNum != 0) { // 进行中 + testPlanWithBLOBs.setStatus(TestPlanStatus.Underway.name()); + editTestPlan(testPlanWithBLOBs); + } + } + public List listTestPlanByProject(QueryTestPlanRequest request) { List testPlans = extTestPlanMapper.list(request); return testPlans; @@ -1086,6 +1123,7 @@ public class TestPlanService { @Transactional(propagation = Propagation.NOT_SUPPORTED) public String run(String testPlanID, String projectID, String userId, String triggerMode, String apiRunConfig) { + extTestPlanMapper.updateActualEndTimeIsNullById(testPlanID); //创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数 TestPlanScheduleReportInfoDTO reportInfoDTO = testPlanReportService.genTestPlanReportBySchedule(projectID, testPlanID, userId, triggerMode);