From aad2f4f52e54540d5101d5a373e298de4d634e6f Mon Sep 17 00:00:00 2001 From: CaptainB Date: Wed, 19 Oct 2022 12:55:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E5=A2=9E=E5=8A=A0=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=BB=93=E6=9E=9C=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/i18n/lang/track/en-US.js | 18 +++- .../frontend/src/i18n/lang/track/zh-CN.js | 16 ++++ .../frontend/src/i18n/lang/track/zh-TW.js | 16 ++++ .../track/TestPlanTaskNotification.vue | 92 ++++++++++++++++++ .../dto/TestPlanApiResultReportDTO.java | 3 +- .../dto/TestPlanFunctionResultReportDTO.java | 3 +- .../dto/TestPlanLoadResultReportDTO.java | 3 +- .../dto/TestPlanUiResultReportDTO.java | 3 +- .../plan/service/TestPlanMessageService.java | 23 ++++- .../plan/components/ScheduleNotification.vue | 95 ++++++++++++++++++- 10 files changed, 261 insertions(+), 11 deletions(-) diff --git a/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js b/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js index 02613e2699..e161e9c62f 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/track/en-US.js @@ -233,9 +233,25 @@ export default { is_scenario_executing: 'Scenario Executing', is_performance_executing: 'Performance Executing', 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_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_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_component_case_count: "Component Case Count", data_name: "Data Name", diff --git a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js index f66ba81ade..99e2471197 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-CN.js @@ -226,9 +226,25 @@ export default { is_scenario_executing: '是否执行场景', is_performance_executing: '是否执行性能', 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_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_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_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_component_case_count: "步骤用例数", data_name: "数据名称", diff --git a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js index 21ddd3a6fb..656562accc 100644 --- a/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js +++ b/framework/sdk-parent/frontend/src/i18n/lang/track/zh-TW.js @@ -226,9 +226,25 @@ export default { is_scenario_executing: '是否執行場景', is_performance_executing: '是否執行性能', 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_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_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_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_component_case_count: "步驟用例數", data_name: "數據名稱", diff --git a/project-management/frontend/src/business/menu/notification/track/TestPlanTaskNotification.vue b/project-management/frontend/src/business/menu/notification/track/TestPlanTaskNotification.vue index a83af111bc..51564b96a9 100644 --- a/project-management/frontend/src/business/menu/notification/track/TestPlanTaskNotification.vue +++ b/project-management/frontend/src/business/menu/notification/track/TestPlanTaskNotification.vue @@ -160,6 +160,98 @@ export default { label: this.$t('report.plan_share_url'), 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' + }, ], }; }, diff --git a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanApiResultReportDTO.java b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanApiResultReportDTO.java index 0fbaac251e..8960169cbf 100644 --- a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanApiResultReportDTO.java +++ b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanApiResultReportDTO.java @@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO; import lombok.Getter; import lombok.Setter; +import java.io.Serializable; import java.util.List; @Getter @Setter -public class TestPlanApiResultReportDTO { +public class TestPlanApiResultReportDTO implements Serializable { private List apiCaseData; private List apiScenarioData; private List apiScenarioStepData; diff --git a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanFunctionResultReportDTO.java b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanFunctionResultReportDTO.java index e70e6a47ba..899bbd2ea4 100644 --- a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanFunctionResultReportDTO.java +++ b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanFunctionResultReportDTO.java @@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO; import lombok.Getter; import lombok.Setter; +import java.io.Serializable; import java.util.List; @Getter @Setter -public class TestPlanFunctionResultReportDTO { +public class TestPlanFunctionResultReportDTO implements Serializable { private List caseData; private List issueData; } diff --git a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanLoadResultReportDTO.java b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanLoadResultReportDTO.java index c44998f25f..6722635fe7 100644 --- a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanLoadResultReportDTO.java +++ b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanLoadResultReportDTO.java @@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO; import lombok.Getter; import lombok.Setter; +import java.io.Serializable; import java.util.List; @Getter @Setter -public class TestPlanLoadResultReportDTO { +public class TestPlanLoadResultReportDTO implements Serializable { private List caseData; } diff --git a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanUiResultReportDTO.java b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanUiResultReportDTO.java index 631d362180..af4148df1e 100644 --- a/test-track/backend/src/main/java/io/metersphere/dto/TestPlanUiResultReportDTO.java +++ b/test-track/backend/src/main/java/io/metersphere/dto/TestPlanUiResultReportDTO.java @@ -4,11 +4,12 @@ import io.metersphere.plan.dto.TestCaseReportStatusResultDTO; import lombok.Getter; import lombok.Setter; +import java.io.Serializable; import java.util.List; @Getter @Setter -public class TestPlanUiResultReportDTO { +public class TestPlanUiResultReportDTO implements Serializable { //历史的case数据 private List uiScenarioCaseData; //场景的分类统计数据 diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java index 51a7a6842c..255ed37a88 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanMessageService.java @@ -5,6 +5,7 @@ import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.commons.constants.*; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.CommonBeanFactory; +import io.metersphere.commons.utils.HttpHeaderUtils; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.*; import io.metersphere.notice.sender.NoticeModel; @@ -122,7 +123,7 @@ public class TestPlanMessageService { assert noticeSendService != null; BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); String url = baseSystemConfigDTO.getUrl() + "/#/track/testPlan/reportList"; - String subject = StringUtils.EMPTY; + String subject; String successContext = "${operator}执行的 ${name} 测试计划运行成功, 报告: ${planShareUrl}"; String failedContext = "${operator}执行的 ${name} 测试计划运行失败, 报告: ${planShareUrl}"; String context = "${operator}完成了测试计划: ${name}, 报告: ${planShareUrl}"; @@ -134,12 +135,15 @@ public class TestPlanMessageService { // 计算通过率 TestPlanDTOWithMetric testPlanDTOWithMetric = BeanUtils.copyBean(new TestPlanDTOWithMetric(), testPlan); testPlanService.calcTestPlanRate(Collections.singletonList(testPlanDTOWithMetric)); - // 计算各种属性 - TestPlanSimpleReportDTO report = testPlanReportService.getReport(testPlanReport.getId()); - Map caseCountMap = calculateCaseCount(report); - String creator = testPlanReport.getCreator(); UserDTO userDTO = baseUserService.getUserDTO(creator); + // 计算各种属性 + HttpHeaderUtils.runAsUser(userDTO); + TestPlanSimpleReportDTO report = testPlanReportService.getReport(testPlanReport.getId()); + HttpHeaderUtils.clearUser(); + + Map caseCountMap = calculateCaseCount(report); + Map paramMap = new HashMap(); paramMap.put("type", "testPlan"); @@ -149,6 +153,15 @@ public class TestPlanMessageService { paramMap.put("operator", userDTO.getName()); 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(new BeanMap(testPlanDTOWithMetric)); diff --git a/test-track/frontend/src/business/plan/components/ScheduleNotification.vue b/test-track/frontend/src/business/plan/components/ScheduleNotification.vue index 9080c05b71..b8d2177aa3 100644 --- a/test-track/frontend/src/business/plan/components/ScheduleNotification.vue +++ b/test-track/frontend/src/business/plan/components/ScheduleNotification.vue @@ -28,6 +28,7 @@ import MsCodeEdit from "metersphere-frontend/src/components/MsCodeEdit"; import MsTipButton from "metersphere-frontend/src/components/MsTipButton"; import NotificationTable from "metersphere-frontend/src/components/notification/NotificationTable"; import MxNoticeTemplate from "metersphere-frontend/src/components/MxNoticeTemplate"; +import {searchNoticeById} from "metersphere-frontend/src/api/notification"; export default { name: "ScheduleNotification", @@ -145,6 +146,98 @@ export default { label: this.$t('report.plan_share_url'), 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: { initForm() { - this.result = this.$get('/notice/search/message/' + this.testId, response => { + this.result = searchNoticeById(this.testId).then(response=> { this.scheduleTask = response.data; }); },