feat(消息通知): 测试计划增加执行结果变量

This commit is contained in:
CaptainB 2022-10-19 12:55:24 +08:00 committed by 刘瑞斌
parent 91cc0052c2
commit aad2f4f52e
10 changed files with 261 additions and 11 deletions

View File

@ -233,9 +233,25 @@ export default {
is_scenario_executing: 'Scenario Executing', is_scenario_executing: 'Scenario Executing',
is_performance_executing: 'Performance Executing', is_performance_executing: 'Performance Executing',
test_plan_test_case_count: "Track Case Count", test_plan_test_case_count: "Track Case Count",
test_plan_test_case_success_count: "Function case success count",
test_plan_test_case_failed_count: "Failed count of functional case",
test_plan_test_case_blocked_count: "Function Case Blocked Count",
test_plan_test_case_prepared_count: "Function Case Prepared Count",
test_plan_test_case_skipped_count: "Function case skipped count",
test_plan_api_case_count: "Api Case Count", test_plan_api_case_count: "Api Case Count",
test_plan_api_case_success_count: "Api Case success Count",
test_plan_api_case_failed_count: "Api Case failed Count",
test_plan_api_case_un_execute_count: "Api Case unexecuted Count",
test_plan_api_case_error_report_count: "Api Case error report Count",
test_plan_api_scenario_count: "Scenario Case Count", test_plan_api_scenario_count: "Scenario Case Count",
test_plan_ui_scenario_count: "Ui Scenario Case Count", test_plan_api_scenario_success_count: "Scenario Case success Count",
test_plan_api_scenario_failed_count: "Scenario Case failed Count",
test_plan_api_scenario_un_execute_count: "Scenario Case unexecuted Count",
test_plan_api_scenario_error_report_count: "Scenario Case error report Count",
test_plan_ui_scenario_count: "UI Scenario Case Count",
test_plan_ui_scenario_success_count: "UI Scenario Case success Count",
test_plan_ui_scenario_failed_count: "UI Scenario Case failed Count",
test_plan_ui_scenario_un_execute_count: "UI Scenario Case unexecuted Count",
test_plan_load_case_count: "Load Case Count", test_plan_load_case_count: "Load Case Count",
test_plan_component_case_count: "Component Case Count", test_plan_component_case_count: "Component Case Count",
data_name: "Data Name", data_name: "Data Name",

View File

@ -226,9 +226,25 @@ export default {
is_scenario_executing: '是否执行场景', is_scenario_executing: '是否执行场景',
is_performance_executing: '是否执行性能', is_performance_executing: '是否执行性能',
test_plan_test_case_count: "功能用例数", test_plan_test_case_count: "功能用例数",
test_plan_test_case_success_count: "功能用例成功数",
test_plan_test_case_failed_count: "功能用例失败数",
test_plan_test_case_blocked_count: "功能用例阻塞数",
test_plan_test_case_prepared_count: "功能用例未开始数",
test_plan_test_case_skipped_count: "功能用例跳过数",
test_plan_api_case_count: "接口用例数", test_plan_api_case_count: "接口用例数",
test_plan_api_case_success_count: "接口用例成功数",
test_plan_api_case_failed_count: "接口用例失败数",
test_plan_api_case_un_execute_count: "接口用例未执行数",
test_plan_api_case_error_report_count: "接口用例误报数",
test_plan_api_scenario_count: "场景用例数", test_plan_api_scenario_count: "场景用例数",
test_plan_api_scenario_success_count: "场景用例成功数",
test_plan_api_scenario_failed_count: "场景用例失败数",
test_plan_api_scenario_un_execute_count: "场景用例未执行数",
test_plan_api_scenario_error_report_count: "场景用例误报数",
test_plan_ui_scenario_count: "UI 场景用例数", test_plan_ui_scenario_count: "UI 场景用例数",
test_plan_ui_scenario_success_count: "UI 场景用例成功数",
test_plan_ui_scenario_failed_count: "UI 场景用例失败数",
test_plan_ui_scenario_un_execute_count: "UI 场景用例未执行数",
test_plan_load_case_count: "性能用例数", test_plan_load_case_count: "性能用例数",
test_plan_component_case_count: "步骤用例数", test_plan_component_case_count: "步骤用例数",
data_name: "数据名称", data_name: "数据名称",

View File

@ -226,9 +226,25 @@ export default {
is_scenario_executing: '是否執行場景', is_scenario_executing: '是否執行場景',
is_performance_executing: '是否執行性能', is_performance_executing: '是否執行性能',
test_plan_test_case_count: "功能用例數", test_plan_test_case_count: "功能用例數",
test_plan_test_case_success_count: "功能用例成功數",
test_plan_test_case_failed_count: "功能用例失敗數",
test_plan_test_case_blocked_count: "功能用例阻塞數",
test_plan_test_case_prepared_count: "功能用例未開始數",
test_plan_test_case_skipped_count: "功能用例跳過數",
test_plan_api_case_count: "接口用例數", test_plan_api_case_count: "接口用例數",
test_plan_api_case_success_count: "接口用例成功數",
test_plan_api_case_failed_count: "接口用例失敗數",
test_plan_api_case_un_execute_count: "接口用例未執行數",
test_plan_api_case_error_report_count: "接口用例誤報數",
test_plan_api_scenario_count: "場景用例數", test_plan_api_scenario_count: "場景用例數",
test_plan_api_scenario_success_count: "場景用例成功數",
test_plan_api_scenario_failed_count: "場景用例失敗數",
test_plan_api_scenario_un_execute_count: "場景用例未執行數",
test_plan_api_scenario_error_report_count: "場景用例誤報數",
test_plan_ui_scenario_count: "UI 場景用例數", test_plan_ui_scenario_count: "UI 場景用例數",
test_plan_ui_scenario_success_count: "UI 場景用例成功數",
test_plan_ui_scenario_failed_count: "UI 場景用例失敗數",
test_plan_ui_scenario_un_execute_count: "UI 場景用例未執行數",
test_plan_load_case_count: "性能用例數", test_plan_load_case_count: "性能用例數",
test_plan_component_case_count: "步驟用例數", test_plan_component_case_count: "步驟用例數",
data_name: "數據名稱", data_name: "數據名稱",

View File

@ -160,6 +160,98 @@ export default {
label: this.$t('report.plan_share_url'), label: this.$t('report.plan_share_url'),
value: 'planShareUrl', value: 'planShareUrl',
}, },
{
label: this.$t('test_track.report.exacutive_rate'),
value: 'executeRate'
},
{
label: this.$t('test_track.report.total_number_tests'),
value: 'caseCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_count'),
value: 'functionAllCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_success_count'),
value: 'functionSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_failed_count'),
value: 'functionFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_blocked_count'),
value: 'functionBlockedCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_prepared_count'),
value: 'functionPreparedCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_skipped_count'),
value: 'functionSkippedCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_count'),
value: 'apiCaseAllCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_success_count'),
value: 'apiCaseSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_failed_count'),
value: 'apiCaseFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_un_execute_count'),
value: 'apiCaseUnExecuteCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_error_report_count'),
value: 'apiCaseErrorReportCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_count'),
value: 'apiScenarioAllCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_success_count'),
value: 'apiScenarioSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_failed_count'),
value: 'apiScenarioFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_un_execute_count'),
value: 'apiScenarioUnExecuteCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_error_report_count'),
value: 'apiScenarioErrorReportCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_count'),
value: 'uiScenarioAllCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_success_count'),
value: 'uiScenarioSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_failed_count'),
value: 'uiScenarioFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_un_execute_count'),
value: 'uiScenarioUnExecuteCount'
},
{
label: this.$t('test_track.plan.test_plan_load_case_count'),
value: 'loadCaseAllCount'
},
], ],
}; };
}, },

View File

@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.util.List; import java.util.List;
@Getter @Getter
@Setter @Setter
public class TestPlanApiResultReportDTO { public class TestPlanApiResultReportDTO implements Serializable {
private List<TestCaseReportStatusResultDTO> apiCaseData; private List<TestCaseReportStatusResultDTO> apiCaseData;
private List<TestCaseReportStatusResultDTO> apiScenarioData; private List<TestCaseReportStatusResultDTO> apiScenarioData;
private List<TestCaseReportStatusResultDTO> apiScenarioStepData; private List<TestCaseReportStatusResultDTO> apiScenarioStepData;

View File

@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.util.List; import java.util.List;
@Getter @Getter
@Setter @Setter
public class TestPlanFunctionResultReportDTO { public class TestPlanFunctionResultReportDTO implements Serializable {
private List<TestCaseReportStatusResultDTO> caseData; private List<TestCaseReportStatusResultDTO> caseData;
private List<TestCaseReportStatusResultDTO> issueData; private List<TestCaseReportStatusResultDTO> issueData;
} }

View File

@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.util.List; import java.util.List;
@Getter @Getter
@Setter @Setter
public class TestPlanLoadResultReportDTO { public class TestPlanLoadResultReportDTO implements Serializable {
private List<TestCaseReportStatusResultDTO> caseData; private List<TestCaseReportStatusResultDTO> caseData;
} }

View File

@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.io.Serializable;
import java.util.List; import java.util.List;
@Getter @Getter
@Setter @Setter
public class TestPlanUiResultReportDTO { public class TestPlanUiResultReportDTO implements Serializable {
//历史的case数据 //历史的case数据
private List<TestCaseReportStatusResultDTO> uiScenarioCaseData; private List<TestCaseReportStatusResultDTO> uiScenarioCaseData;
//场景的分类统计数据 //场景的分类统计数据

View File

@ -5,6 +5,7 @@ import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.commons.constants.*; import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.HttpHeaderUtils;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.*; import io.metersphere.dto.*;
import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.sender.NoticeModel;
@ -122,7 +123,7 @@ public class TestPlanMessageService {
assert noticeSendService != null; assert noticeSendService != null;
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
String url = baseSystemConfigDTO.getUrl() + "/#/track/testPlan/reportList"; String url = baseSystemConfigDTO.getUrl() + "/#/track/testPlan/reportList";
String subject = StringUtils.EMPTY; String subject;
String successContext = "${operator}执行的 ${name} 测试计划运行成功, 报告: ${planShareUrl}"; String successContext = "${operator}执行的 ${name} 测试计划运行成功, 报告: ${planShareUrl}";
String failedContext = "${operator}执行的 ${name} 测试计划运行失败, 报告: ${planShareUrl}"; String failedContext = "${operator}执行的 ${name} 测试计划运行失败, 报告: ${planShareUrl}";
String context = "${operator}完成了测试计划: ${name}, 报告: ${planShareUrl}"; String context = "${operator}完成了测试计划: ${name}, 报告: ${planShareUrl}";
@ -134,12 +135,15 @@ public class TestPlanMessageService {
// 计算通过率 // 计算通过率
TestPlanDTOWithMetric testPlanDTOWithMetric = BeanUtils.copyBean(new TestPlanDTOWithMetric(), testPlan); TestPlanDTOWithMetric testPlanDTOWithMetric = BeanUtils.copyBean(new TestPlanDTOWithMetric(), testPlan);
testPlanService.calcTestPlanRate(Collections.singletonList(testPlanDTOWithMetric)); testPlanService.calcTestPlanRate(Collections.singletonList(testPlanDTOWithMetric));
// 计算各种属性
TestPlanSimpleReportDTO report = testPlanReportService.getReport(testPlanReport.getId());
Map<String, Long> caseCountMap = calculateCaseCount(report);
String creator = testPlanReport.getCreator(); String creator = testPlanReport.getCreator();
UserDTO userDTO = baseUserService.getUserDTO(creator); UserDTO userDTO = baseUserService.getUserDTO(creator);
// 计算各种属性
HttpHeaderUtils.runAsUser(userDTO);
TestPlanSimpleReportDTO report = testPlanReportService.getReport(testPlanReport.getId());
HttpHeaderUtils.clearUser();
Map<String, Long> caseCountMap = calculateCaseCount(report);
Map paramMap = new HashMap(); Map paramMap = new HashMap();
paramMap.put("type", "testPlan"); paramMap.put("type", "testPlan");
@ -149,6 +153,15 @@ public class TestPlanMessageService {
paramMap.put("operator", userDTO.getName()); paramMap.put("operator", userDTO.getName());
paramMap.put("executor", userDTO.getId()); paramMap.put("executor", userDTO.getId());
} }
// 执行率 通过率 两位小数
if (report.getPassRate() != null && !report.getPassRate().isNaN()) {
paramMap.put("passRate", String.format("%.2f", report.getPassRate() * 100));
}
if (report.getExecuteRate() != null && !report.getExecuteRate().isNaN()) {
paramMap.put("executeRate", String.format("%.2f", report.getExecuteRate() * 100));
}
paramMap.putAll(caseCountMap); paramMap.putAll(caseCountMap);
paramMap.putAll(new BeanMap(testPlanDTOWithMetric)); paramMap.putAll(new BeanMap(testPlanDTOWithMetric));

View File

@ -28,6 +28,7 @@ import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit";
import MsTipButton from "metersphere-frontend/src/components/MsTipButton"; import MsTipButton from "metersphere-frontend/src/components/MsTipButton";
import NotificationTable from "metersphere-frontend/src/components/notification/NotificationTable"; import NotificationTable from "metersphere-frontend/src/components/notification/NotificationTable";
import MxNoticeTemplate from "metersphere-frontend/src/components/MxNoticeTemplate"; import MxNoticeTemplate from "metersphere-frontend/src/components/MxNoticeTemplate";
import {searchNoticeById} from "metersphere-frontend/src/api/notification";
export default { export default {
name: "ScheduleNotification", name: "ScheduleNotification",
@ -145,6 +146,98 @@ export default {
label: this.$t('report.plan_share_url'), label: this.$t('report.plan_share_url'),
value: 'planShareUrl', value: 'planShareUrl',
}, },
{
label: this.$t('test_track.report.exacutive_rate'),
value: 'executeRate'
},
{
label: this.$t('test_track.report.total_number_tests'),
value: 'caseCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_count'),
value: 'functionAllCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_success_count'),
value: 'functionSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_failed_count'),
value: 'functionFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_blocked_count'),
value: 'functionBlockedCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_prepared_count'),
value: 'functionPreparedCount'
},
{
label: this.$t('test_track.plan.test_plan_test_case_skipped_count'),
value: 'functionSkippedCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_count'),
value: 'apiCaseAllCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_success_count'),
value: 'apiCaseSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_failed_count'),
value: 'apiCaseFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_un_execute_count'),
value: 'apiCaseUnExecuteCount'
},
{
label: this.$t('test_track.plan.test_plan_api_case_error_report_count'),
value: 'apiCaseErrorReportCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_count'),
value: 'apiScenarioAllCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_success_count'),
value: 'apiScenarioSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_failed_count'),
value: 'apiScenarioFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_un_execute_count'),
value: 'apiScenarioUnExecuteCount'
},
{
label: this.$t('test_track.plan.test_plan_api_scenario_error_report_count'),
value: 'apiScenarioErrorReportCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_count'),
value: 'uiScenarioAllCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_success_count'),
value: 'uiScenarioSuccessCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_failed_count'),
value: 'uiScenarioFailedCount'
},
{
label: this.$t('test_track.plan.test_plan_ui_scenario_un_execute_count'),
value: 'uiScenarioUnExecuteCount'
},
{
label: this.$t('test_track.plan.test_plan_load_case_count'),
value: 'loadCaseAllCount'
},
], ],
}; };
}, },
@ -161,7 +254,7 @@ export default {
}, },
methods: { methods: {
initForm() { initForm() {
this.result = this.$get('/notice/search/message/' + this.testId, response => { this.result = searchNoticeById(this.testId).then(response=> {
this.scheduleTask = response.data; this.scheduleTask = response.data;
}); });
}, },