From 7c9388ee5aaa5a495bea8c99efebc61ca547798c Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 23 Feb 2023 11:22:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=BB=9F=E8=AE=A1=E6=97=B6=E7=BB=9F=E8=AE=A1=E4=BA=86?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=89=8D=E5=90=8E=E7=BD=AE=E8=84=9A=E6=9C=AC?= =?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 修复接口测试报告统计时统计了全局前后置脚本的问题 --- .../service/plan/TestPlanScenarioCaseService.java | 15 ++++++++++----- .../ApiScenarioReportStructureService.java | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index 8c15bd5af5..64fed84a78 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -351,11 +351,16 @@ public class TestPlanScenarioCaseService { map.put(s, envMap.get(s)); } } - - testPlanApiScenario.setEnvironmentType(runModeConfig.getEnvironmentType()); - testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId()); - testPlanApiScenario.setEnvironment(JSON.toJSONString(map)); - mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario); + + String envJsonStr = JSON.toJSONString(map); + if (!StringUtils.equals(envJsonStr, testPlanApiScenario.getEnvironment()) + || !StringUtils.equals(runModeConfig.getEnvironmentType(), testPlanApiScenario.getEnvironmentType()) + || !StringUtils.equals(runModeConfig.getEnvironmentGroupId(), testPlanApiScenario.getEnvironmentGroupId())) { + testPlanApiScenario.setEnvironmentType(runModeConfig.getEnvironmentType()); + testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId()); + testPlanApiScenario.setEnvironment(envJsonStr); + mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario); + } } sqlSession.flushStatements(); if (sqlSession != null && sqlSessionFactory != null) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java index 345c9a0101..d93044fd5a 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioReportStructureService.java @@ -567,6 +567,8 @@ public class ApiScenarioReportStructureService { if (CollectionUtils.isNotEmpty(reportStructureWithBLOBs) && CollectionUtils.isNotEmpty(reportResults)) { ApiScenarioReportStructureWithBLOBs scenarioReportStructure = reportStructureWithBLOBs.get(0); List stepList = JSON.parseArray(new String(scenarioReportStructure.getResourceTree(), StandardCharsets.UTF_8), StepTreeDTO.class); + //过滤掉前后置脚本。否则会影响到下面几行的统计数据。 + reportResults = this.filterProcessResult(reportResults); reportDTO.setTotal(reportResults.size()); reportDTO.setError(reportResults.stream().filter(e -> StringUtils.equals(e.getStatus(), ApiReportStatus.ERROR.name())).collect(Collectors.toList()).size());