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

@ -351,11 +351,16 @@ public class TestPlanScenarioCaseService {
map.put(s, envMap.get(s)); map.put(s, envMap.get(s));
} }
} }
testPlanApiScenario.setEnvironmentType(runModeConfig.getEnvironmentType()); String envJsonStr = JSON.toJSONString(map);
testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId()); if (!StringUtils.equals(envJsonStr, testPlanApiScenario.getEnvironment())
testPlanApiScenario.setEnvironment(JSON.toJSONString(map)); || !StringUtils.equals(runModeConfig.getEnvironmentType(), testPlanApiScenario.getEnvironmentType())
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario); || !StringUtils.equals(runModeConfig.getEnvironmentGroupId(), testPlanApiScenario.getEnvironmentGroupId())) {
testPlanApiScenario.setEnvironmentType(runModeConfig.getEnvironmentType());
testPlanApiScenario.setEnvironmentGroupId(runModeConfig.getEnvironmentGroupId());
testPlanApiScenario.setEnvironment(envJsonStr);
mapper.updateByPrimaryKeyWithBLOBs(testPlanApiScenario);
}
} }
sqlSession.flushStatements(); sqlSession.flushStatements();
if (sqlSession != null && sqlSessionFactory != null) { if (sqlSession != null && sqlSessionFactory != null) {

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());