fix(接口测试): 修复接口测试报告统计时统计了全局前后置脚本的问题

修复接口测试报告统计时统计了全局前后置脚本的问题
This commit is contained in:
song-tianyang 2023-02-23 11:22:40 +08:00 committed by 建国
parent dd711ca03b
commit 7c9388ee5a
2 changed files with 12 additions and 5 deletions

View File

@ -352,11 +352,16 @@ public class TestPlanScenarioCaseService {
} }
} }
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.setEnvironmentType(runModeConfig.getEnvironmentType());
testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId()); testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId());
testPlanApiScenario.setEnvironment(JSON.toJSONString(map)); testPlanApiScenario.setEnvironment(envJsonStr);
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario); mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario);
} }
}
sqlSession.flushStatements(); sqlSession.flushStatements();
if (sqlSession != null && sqlSessionFactory != null) { if (sqlSession != null && sqlSessionFactory != null) {
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);

View File

@ -567,6 +567,8 @@ public class ApiScenarioReportStructureService {
if (CollectionUtils.isNotEmpty(reportStructureWithBLOBs) && CollectionUtils.isNotEmpty(reportResults)) { if (CollectionUtils.isNotEmpty(reportStructureWithBLOBs) && CollectionUtils.isNotEmpty(reportResults)) {
ApiScenarioReportStructureWithBLOBs scenarioReportStructure = reportStructureWithBLOBs.get(0); ApiScenarioReportStructureWithBLOBs scenarioReportStructure = reportStructureWithBLOBs.get(0);
List<StepTreeDTO> stepList = JSON.parseArray(new String(scenarioReportStructure.getResourceTree(), StandardCharsets.UTF_8), StepTreeDTO.class); List<StepTreeDTO> stepList = JSON.parseArray(new String(scenarioReportStructure.getResourceTree(), StandardCharsets.UTF_8), StepTreeDTO.class);
//过滤掉前后置脚本否则会影响到下面几行的统计数据
reportResults = this.filterProcessResult(reportResults);
reportDTO.setTotal(reportResults.size()); reportDTO.setTotal(reportResults.size());
reportDTO.setError(reportResults.stream().filter(e -> StringUtils.equals(e.getStatus(), ApiReportStatus.ERROR.name())).collect(Collectors.toList()).size()); reportDTO.setError(reportResults.stream().filter(e -> StringUtils.equals(e.getStatus(), ApiReportStatus.ERROR.name())).collect(Collectors.toList()).size());