fix(测试跟踪): [测试计划]github#14224-测试报告中场景id缺失

--bug=1013722 --user=宋天阳 [测试计划]github#14224-测试报告中场景id缺失
https://www.tapd.cn/55049933/s/1170922
This commit is contained in:
song-tianyang 2022-06-01 14:31:52 +08:00 committed by TIanyang
parent b8e1b1b5ec
commit 9fe3acfd6d
5 changed files with 22 additions and 63 deletions

View File

@ -16,4 +16,6 @@ public class TestPlanExecuteReportDTO {
private Map<String,String> testPlanApiCaseIdAndReportIdMap;
private Map<String,String> testPlanScenarioIdAndReportIdMap;
private Map<String,String> testPlanLoadCaseIdAndReportIdMap;
private Map<String,TestPlanFailureApiDTO> apiCaseInfoDTOMap;
private Map<String,TestPlanFailureScenarioDTO> scenarioInfoDTOMap;
}

View File

@ -428,15 +428,15 @@ public class TestPlanApiCaseService {
testPlanApiCaseMapper::updateByPrimaryKeySelective);
}
public List<TestPlanFailureApiDTO> getByApiExecReportIds(Map<String, String> testPlanApiCaseReportMap) {
public List<TestPlanFailureApiDTO> getByApiExecReportIds(Map<String, String> testPlanApiCaseReportMap, Map<String, TestPlanFailureApiDTO> apiCaseInfoDTOMap) {
if (testPlanApiCaseReportMap.isEmpty()) {
return new ArrayList<>();
}
String defaultStatus = "error";
List<TestPlanFailureApiDTO> apiTestCases = extTestPlanApiCaseMapper.getFailureListByIds(testPlanApiCaseReportMap.keySet(), null);
Map<String, String> reportResult = apiDefinitionExecResultService.selectReportResultByReportIds(testPlanApiCaseReportMap.values());
Map<String, String> savedReportMap = new HashMap<>(testPlanApiCaseReportMap);
for (TestPlanFailureApiDTO dto : apiTestCases) {
List<TestPlanFailureApiDTO> apiTestCases = new ArrayList<>();
for (TestPlanFailureApiDTO dto : apiCaseInfoDTOMap.values()) {
String testPlanApiCaseId = dto.getId();
String reportId = savedReportMap.get(testPlanApiCaseId);
savedReportMap.remove(testPlanApiCaseId);
@ -450,28 +450,8 @@ public class TestPlanApiCaseService {
}
dto.setExecResult(status);
}
}
if (!MapUtils.isEmpty(savedReportMap)) {
for (Map.Entry<String, String> entry : savedReportMap.entrySet()) {
String testPlanApiCaseId = entry.getKey();
String reportId = entry.getValue();
TestPlanFailureApiDTO dto = new TestPlanFailureApiDTO();
dto.setId(testPlanApiCaseId);
dto.setReportId(reportId);
dto.setName("DELETED");
dto.setNum(0);
if (StringUtils.isEmpty(reportId)) {
dto.setExecResult(defaultStatus);
} else {
String status = reportResult.get(reportId);
if (status == null) {
status = defaultStatus;
}
dto.setExecResult(status);
}
apiTestCases.add(dto);
}
}
return buildCases(apiTestCases);
}

View File

@ -961,10 +961,12 @@ public class TestPlanReportService {
Map<String, String> testPlanApiCaseIdAndReportIdMap = new HashMap<>();
Map<String, String> testPlanScenarioIdAndReportIdMap = new HashMap<>();
Map<String, String> testPlanLoadCaseIdAndReportIdMap = new HashMap<>();
List<TestPlanFailureApiDTO> apiCaseInfoDTOList = null;
List<TestPlanFailureScenarioDTO> scenarioInfoDTOList = null;
Map<String,TestPlanFailureApiDTO> apiCaseInfoDTOMap = new HashMap<>();
Map<String,TestPlanFailureScenarioDTO> scenarioInfoDTOMap = new HashMap<>();
if (testPlanReportContentWithBLOBs != null) {
if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct())) {
List<TestPlanFailureApiDTO> apiCaseInfoDTOList = null;
try {
apiCaseInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct(), TestPlanFailureApiDTO.class);
} catch (Exception ignored) {
@ -977,10 +979,12 @@ public class TestPlanReportService {
} else {
for (TestPlanFailureApiDTO item : apiCaseInfoDTOList) {
testPlanApiCaseIdAndReportIdMap.put(item.getId(), item.getReportId());
apiCaseInfoDTOMap.put(item.getId(),item);
}
}
}
if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct())) {
List<TestPlanFailureScenarioDTO> scenarioInfoDTOList = null;
try {
scenarioInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct(), TestPlanFailureScenarioDTO.class);
} catch (Exception ignored) {
@ -993,6 +997,7 @@ public class TestPlanReportService {
} else {
for (TestPlanFailureScenarioDTO item : scenarioInfoDTOList) {
testPlanScenarioIdAndReportIdMap.put(item.getId(), item.getReportId());
scenarioInfoDTOMap.put(item.getId(),item);
}
}
}
@ -1003,7 +1008,7 @@ public class TestPlanReportService {
}
}
}
TestPlanExecuteReportDTO returnDTO = new TestPlanExecuteReportDTO(testPlanApiCaseIdAndReportIdMap, testPlanScenarioIdAndReportIdMap, testPlanLoadCaseIdAndReportIdMap);
TestPlanExecuteReportDTO returnDTO = new TestPlanExecuteReportDTO(testPlanApiCaseIdAndReportIdMap, testPlanScenarioIdAndReportIdMap, testPlanLoadCaseIdAndReportIdMap, apiCaseInfoDTOMap, scenarioInfoDTOMap);
return returnDTO;
}

View File

@ -100,7 +100,7 @@ public class TestPlanScenarioCaseService {
Project project = projectMap.get(item.getProjectId());
if(project != null){
ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.SCENARIO_CUSTOM_NUM.name());
boolean custom = config.getCaseCustomNum();
boolean custom = config.getScenarioCustomNum();
if (custom) {
item.setCustomNum(item.getCustomNum());
}else {
@ -528,15 +528,12 @@ public class TestPlanScenarioCaseService {
return buildCases(apiTestCases);
}
public List<TestPlanFailureScenarioDTO> getAllCases(Map<String, String> idMap) {
List<TestPlanFailureScenarioDTO> apiTestCases =
extTestPlanScenarioCaseMapper.getFailureListByIds(idMap.keySet(), null);
public List<TestPlanFailureScenarioDTO> getAllCases(Map<String, String> idMap, Map<String, TestPlanFailureScenarioDTO> scenarioInfoDTOMap) {
String defaultStatus = "Fail";
Map<String, String> reportStatus = apiScenarioReportService.getReportStatusByReportIds(idMap.values());
Map<String, String> savedReportMap = new HashMap<>(idMap);
for (TestPlanFailureScenarioDTO dto : apiTestCases) {
List<TestPlanFailureScenarioDTO> apiTestCases = new ArrayList<>();
for (TestPlanFailureScenarioDTO dto : scenarioInfoDTOMap.values()) {
String reportId = savedReportMap.get(dto.getId());
savedReportMap.remove(dto.getId());
dto.setReportId(reportId);
@ -552,33 +549,8 @@ public class TestPlanScenarioCaseService {
dto.setLastResult(status);
dto.setStatus(status);
}
}
if (!MapUtils.isEmpty(savedReportMap)) {
for (Map.Entry<String, String> entry : savedReportMap.entrySet()) {
String testPlanApiCaseId = entry.getKey();
String reportId = entry.getValue();
TestPlanFailureScenarioDTO dto = new TestPlanFailureScenarioDTO();
dto.setId(testPlanApiCaseId);
dto.setReportId(reportId);
dto.setName("DELETED");
dto.setNum(0);
if (StringUtils.isNotEmpty(reportId)) {
String status = reportStatus.get(reportId);
if (status == null) {
status = defaultStatus;
} else {
if (StringUtils.equalsIgnoreCase(status, "Error")) {
status = "Fail";
}
}
dto.setLastResult(status);
dto.setStatus(status);
}
apiTestCases.add(dto);
}
}
return buildCases(apiTestCases);
}

View File

@ -1544,9 +1544,9 @@ public class TestPlanService {
List<TestPlanFailureScenarioDTO> scenarioAllCases = null;
if (checkReportConfig(config, "api", "all")) {
// 接口
apiAllCases = testPlanApiCaseService.getByApiExecReportIds(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap());
apiAllCases = testPlanApiCaseService.getByApiExecReportIds(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap(),testPlanExecuteReportDTO.getApiCaseInfoDTOMap());
//场景
scenarioAllCases = testPlanScenarioCaseService.getAllCases(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap());
scenarioAllCases = testPlanScenarioCaseService.getAllCases(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap(),testPlanExecuteReportDTO.getScenarioInfoDTOMap());
this.checkApiCaseCreatorName(apiAllCases, scenarioAllCases);
report.setApiAllCases(apiAllCases);
report.setScenarioAllCases(scenarioAllCases);