fix(测试跟踪): 测试计划报告-报告表头增加的运行耗时和成功率不正确问题修复
--bug=1009805 --user=周骏弘 【测试跟踪】-报告-报告表头增加的运行耗时和成功率不正确 https://www.tapd.cn/55049933/s/1096595
This commit is contained in:
parent
9569c02bb4
commit
6c5a541cfa
|
@ -92,7 +92,7 @@
|
||||||
SELECT tpr.id AS id, tpr.`name` AS `name`, tp.`name` AS testPlanName,
|
SELECT tpr.id AS id, tpr.`name` AS `name`, tp.`name` AS testPlanName,
|
||||||
IF(u.name is null,tpr.creator,u.name)AS creator, tpr.is_new, tpr.test_plan_id,
|
IF(u.name is null,tpr.creator,u.name)AS creator, tpr.is_new, tpr.test_plan_id,
|
||||||
tpr.create_time AS createTime,tpr.trigger_mode AS triggerMode,tpr.status AS status,
|
tpr.create_time AS createTime,tpr.trigger_mode AS triggerMode,tpr.status AS status,
|
||||||
tpr.end_time AS endTime, (tpr.end_time - tpr.create_time) AS runTime, tprc.pass_rate AS passRate
|
tprc.end_time AS endTime, (tprc.end_time - tprc.start_time) AS runTime, tprc.pass_rate AS passRate
|
||||||
FROM test_plan tp
|
FROM test_plan tp
|
||||||
INNER JOIN test_plan_report tpr on tp.id = tpr.test_plan_id
|
INNER JOIN test_plan_report tpr on tp.id = tpr.test_plan_id
|
||||||
LEFT JOIN user u on tpr.creator = u.id
|
LEFT JOIN user u on tpr.creator = u.id
|
||||||
|
|
|
@ -81,6 +81,14 @@ public class TestPlanReportService {
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
private ProjectService projectService;
|
private ProjectService projectService;
|
||||||
|
@Resource
|
||||||
|
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtLoadTestReportMapper extLoadTestReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiScenarioReportMapper extApiScenarioReportMapper;
|
||||||
|
|
||||||
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
|
public List<TestPlanReportDTO> list(QueryTestPlanReportRequest request) {
|
||||||
List<TestPlanReportDTO> list = new ArrayList<>();
|
List<TestPlanReportDTO> list = new ArrayList<>();
|
||||||
|
@ -109,9 +117,88 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list = extTestPlanReportMapper.list(request);
|
list = extTestPlanReportMapper.list(request);
|
||||||
|
|
||||||
|
// 设置测试计划报告成功率
|
||||||
|
setTestPlanReportPassRate(list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTestPlanReportPassRate(List<TestPlanReportDTO> list){
|
||||||
|
for(TestPlanReportDTO testPlanReportDTO : list){
|
||||||
|
TestPlanReportContentExample example = new TestPlanReportContentExample();
|
||||||
|
example.createCriteria().andTestPlanReportIdEqualTo(testPlanReportDTO.getId());
|
||||||
|
List<TestPlanReportContentWithBLOBs> testPlanReportContents = testPlanReportContentMapper.selectByExampleWithBLOBs(example);
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(testPlanReportContents)) {
|
||||||
|
TestPlanReportContentWithBLOBs testPlanReportContent = testPlanReportContents.get(0);
|
||||||
|
if (testPlanReportContent != null) {
|
||||||
|
if (this.isDynamicallyGenerateReports(testPlanReportContent)) {
|
||||||
|
String planId = testPlanReportDTO.getTestPlanId();
|
||||||
|
TestPlanSimpleReportDTO report = new TestPlanSimpleReportDTO();
|
||||||
|
Map<String, TestCaseReportStatusResultDTO> statusResultMap = new HashMap<>();
|
||||||
|
|
||||||
|
TestPlanExecuteReportDTO testPlanExecuteReportDTO = genTestPlanExecuteReportDTOByTestPlanReportContent(testPlanReportContent);
|
||||||
|
// 功能用例
|
||||||
|
TestPlanUtils.buildStatusResultMap(extTestPlanTestCaseMapper.selectForPlanReport(planId), statusResultMap, report, TestPlanTestCaseStatus.Pass.name());
|
||||||
|
|
||||||
|
if (testPlanExecuteReportDTO == null) {
|
||||||
|
// 接口用例
|
||||||
|
List<PlanReportCaseDTO> planReportApiCaseDTOS = extTestPlanApiCaseMapper.selectForPlanReport(planId);
|
||||||
|
TestPlanUtils.buildStatusResultMap(planReportApiCaseDTOS, statusResultMap, report, "success");
|
||||||
|
// 场景用例
|
||||||
|
List<PlanReportCaseDTO> planReportScenarioCaseDTOS = extTestPlanScenarioCaseMapper.selectForPlanReport(planId);
|
||||||
|
TestPlanUtils.buildStatusResultMap(planReportScenarioCaseDTOS, statusResultMap, report, "Success");
|
||||||
|
// 性能用例
|
||||||
|
List<PlanReportCaseDTO> planReportLoadCaseDTOS = extTestPlanLoadCaseMapper.selectForPlanReport(planId);
|
||||||
|
TestPlanUtils.buildStatusResultMap(planReportLoadCaseDTOS, statusResultMap, report, TestPlanLoadCaseStatus.success.name());
|
||||||
|
}else{
|
||||||
|
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap())) {
|
||||||
|
// 接口用例
|
||||||
|
List<String> apiReportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap().values());
|
||||||
|
List<PlanReportCaseDTO> planReportCaseDTOS = extApiDefinitionExecResultMapper.selectForPlanReport(apiReportIds);
|
||||||
|
TestPlanUtils.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, "success");
|
||||||
|
}
|
||||||
|
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap())) {
|
||||||
|
// 场景用例
|
||||||
|
List<String> reportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap().values());
|
||||||
|
List<PlanReportCaseDTO> planReportCaseDTOS = extApiScenarioReportMapper.selectForPlanReport(reportIds);
|
||||||
|
TestPlanUtils.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, "Success");
|
||||||
|
}
|
||||||
|
if (MapUtils.isNotEmpty(testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap())) {
|
||||||
|
// 性能用例
|
||||||
|
List<String> reportIds = new ArrayList<>(testPlanExecuteReportDTO.getTestPlanLoadCaseIdAndReportIdMap().values());
|
||||||
|
List<PlanReportCaseDTO> planReportCaseDTOS = extLoadTestReportMapper.selectForPlanReport(reportIds);
|
||||||
|
// 性能测试的报告状态跟用例的执行状态不一样
|
||||||
|
planReportCaseDTOS.forEach(item -> {
|
||||||
|
if (item.getStatus().equals(PerformanceTestStatus.Completed.name())) {
|
||||||
|
item.setStatus(TestPlanLoadCaseStatus.success.name());
|
||||||
|
} else if (item.getStatus().equals(PerformanceTestStatus.Error.name())) {
|
||||||
|
item.setStatus(TestPlanLoadCaseStatus.error.name());
|
||||||
|
} else {
|
||||||
|
item.setStatus(TestPlanLoadCaseStatus.run.name());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
TestPlanUtils.buildStatusResultMap(planReportCaseDTOS, statusResultMap, report, TestPlanLoadCaseStatus.success.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 设置成功率
|
||||||
|
if (report.getCaseCount() != null && report.getExecuteCount() != 0) {
|
||||||
|
report.setExecuteRate(report.getExecuteCount() * 0.1 * 10 / report.getCaseCount());
|
||||||
|
} else {
|
||||||
|
report.setExecuteRate(0.0);
|
||||||
|
}
|
||||||
|
if (report.getPassCount() != 0 && report.getCaseCount() != null) {
|
||||||
|
report.setPassRate(report.getPassCount() * 0.1 * 10 / report.getExecuteCount());
|
||||||
|
} else {
|
||||||
|
report.setPassRate(0.0);
|
||||||
|
}
|
||||||
|
testPlanReportDTO.setPassRate(report.getPassRate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String projectID, String planId, String userId, String triggerMode) {
|
public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String projectID, String planId, String userId, String triggerMode) {
|
||||||
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
Map<String, String> planScenarioIdMap = new LinkedHashMap<>();
|
||||||
Map<String, String> planTestCaseIdMap = new LinkedHashMap<>();
|
Map<String, String> planTestCaseIdMap = new LinkedHashMap<>();
|
||||||
|
|
|
@ -101,7 +101,6 @@
|
||||||
prop="passRate"
|
prop="passRate"
|
||||||
:field="item"
|
:field="item"
|
||||||
:fields-width="fieldsWidth"
|
:fields-width="fieldsWidth"
|
||||||
sortable="custom"
|
|
||||||
:label="$t('test_track.report.list.pass_rate')">
|
:label="$t('test_track.report.list.pass_rate')">
|
||||||
<template v-slot:default="scope">
|
<template v-slot:default="scope">
|
||||||
<span>{{ (scope.row.passRate ? (scope.row.passRate * 100 ).toFixed(1) : 0) + '%'}}</span>
|
<span>{{ (scope.row.passRate ? (scope.row.passRate * 100 ).toFixed(1) : 0) + '%'}}</span>
|
||||||
|
|
Loading…
Reference in New Issue