From 59f61557e3b18dcedab2ccbca99874c095adb1bc Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Mon, 22 Nov 2021 14:42:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=8A=A5=E5=91=8A):=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E6=8A=A5=E5=91=8A=E5=86=85=E6=A1=88=E4=BE=8B?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=8A=B6=E6=80=81=E6=9C=AA=E5=BE=97=E5=88=B0?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1008171 --user=宋天阳 【测试计划】-执行定时任务后报告中接口+场景和性能用例执行状态未更新 https://www.tapd.cn/55049933/s/1071846 --- .../track/service/TestPlanReportService.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) 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 3ce7fc1505..002e554693 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -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 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 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);