refactor(接口测试): 优化场景报告步骤排序方法,以解决存在未执行步骤时报告步骤排序错乱的问题
--bug=1011633 --user=宋天阳 【测试跟踪】-测试报告中功能用例ID顺序和测试计划功能用例顺序不一致 https://www.tapd.cn/55049933/s/1126292
This commit is contained in:
parent
8e1302f23b
commit
7ff56b4d01
|
@ -298,7 +298,7 @@ public class ApiScenarioReportStructureService {
|
|||
requestResultExpandDTO.setName(dto.getLabel());
|
||||
dto.setTotalStatus("unexecute");
|
||||
dto.setValue(requestResultExpandDTO);
|
||||
} else if(StringUtils.isNotEmpty(dto.getType()) && controls.contains(dto.getType()) && dto.getValue() == null){
|
||||
} else if (StringUtils.isNotEmpty(dto.getType()) && controls.contains(dto.getType()) && dto.getValue() == null) {
|
||||
RequestResultExpandDTO requestResultExpandDTO = new RequestResultExpandDTO();
|
||||
requestResultExpandDTO.setStatus("success");
|
||||
requestResultExpandDTO.setName(dto.getLabel());
|
||||
|
@ -383,25 +383,12 @@ public class ApiScenarioReportStructureService {
|
|||
if (dtoList.stream().filter(e -> e.getValue() != null).collect(Collectors.toList()).size() == dtoList.size()) {
|
||||
List<StepTreeDTO> unList = dtoList.stream().filter(e -> e.getValue() != null
|
||||
&& StringUtils.equalsIgnoreCase(e.getTotalStatus(), "unexecute")).collect(Collectors.toList());
|
||||
Map<String, Integer> map = unList.stream().collect(Collectors.toMap(StepTreeDTO::getResourceId, StepTreeDTO::getIndex));
|
||||
|
||||
List<StepTreeDTO> list = dtoList.stream()
|
||||
.sorted(
|
||||
(x, y) -> {
|
||||
// 如果开始时间是0,即未开始,则排后面
|
||||
if (x.getValue().getStartTime() == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return x.getValue().getStartTime() - y.getValue().getStartTime() > 0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
if (map.containsKey(list.get(index).getResourceId())) {
|
||||
Collections.swap(list, index, (map.get(list.get(index).getResourceId()) - 1));
|
||||
}
|
||||
List<StepTreeDTO> list = dtoList.stream().filter(e -> e.getValue().getStartTime() != 0).collect(Collectors.toList());
|
||||
list = list.stream().sorted(Comparator.comparing(x -> x.getValue().getStartTime())).collect(Collectors.toList());
|
||||
unList = unList.stream().sorted(Comparator.comparing(x -> x.getIndex())).collect(Collectors.toList());
|
||||
for (StepTreeDTO unListDTO : unList) {
|
||||
int index = unListDTO.getIndex();
|
||||
list.add(index - 1, unListDTO);
|
||||
}
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
list.get(index).setIndex((index + 1));
|
||||
|
@ -480,7 +467,7 @@ public class ApiScenarioReportStructureService {
|
|||
if (CollectionUtils.isNotEmpty(reportResults)) {
|
||||
reportDTO.setTotal(reportResults.size());
|
||||
reportDTO.setError(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "Error")).collect(Collectors.toList()).size());
|
||||
reportDTO.setUnExecute(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "STOP","unexecute")).collect(Collectors.toList()).size());
|
||||
reportDTO.setUnExecute(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "STOP", "unexecute")).collect(Collectors.toList()).size());
|
||||
reportDTO.setErrorCode(reportResults.stream().filter(e -> StringUtils.equalsAnyIgnoreCase(e.getStatus(), "errorReportResult")).collect(Collectors.toList()).size());
|
||||
reportDTO.setPassAssertions(reportResults.stream().mapToLong(ApiDefinitionExecResultVo::getPassAssertions).sum());
|
||||
reportDTO.setTotalAssertions(reportResults.stream().mapToLong(ApiDefinitionExecResultVo::getTotalAssertions).sum());
|
||||
|
@ -543,7 +530,7 @@ public class ApiScenarioReportStructureService {
|
|||
AtomicLong stepError = new AtomicLong();
|
||||
AtomicLong stepTotal = new AtomicLong();
|
||||
|
||||
reportDTO.setScenarioSuccess((reportDTO.getScenarioTotal() - reportDTO.getScenarioError() - reportDTO.getScenarioUnExecute() -reportDTO.getScenarioErrorReport()));
|
||||
reportDTO.setScenarioSuccess((reportDTO.getScenarioTotal() - reportDTO.getScenarioError() - reportDTO.getScenarioUnExecute() - reportDTO.getScenarioErrorReport()));
|
||||
|
||||
//统计步骤数据
|
||||
AtomicLong stepErrorCode = new AtomicLong();
|
||||
|
|
Loading…
Reference in New Issue