From d3d3d1b21b9cbb276d34f0152d4238e387af2917 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Tue, 31 May 2022 11:08:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E9=9B=86=E6=88=90=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=8A=B6=E6=80=81=E5=8F=AA=E6=9C=89=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=92=8C=E6=88=90=E5=8A=9F=E4=B8=A4=E7=A7=8D=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1013583 --user=宋天阳 【接口测试】批量执行 误报 场景,集合报告,报告状态不是误报 https://www.tapd.cn/55049933/s/1169496 --- .../api/service/ApiScenarioReportService.java | 31 ++++++++++++++++--- .../ext/ExtApiScenarioReportResultMapper.java | 1 + .../ext/ExtApiScenarioReportResultMapper.xml | 5 +++ .../business/components/task/TaskCenter.vue | 6 +++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 7a3cc975f7..6c01776212 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -13,6 +13,7 @@ import io.metersphere.api.jmeter.FixedCapacityUtils; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper; +import io.metersphere.base.mapper.ext.ExtApiScenarioReportResultMapper; import io.metersphere.commons.constants.*; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; @@ -83,6 +84,8 @@ public class ApiScenarioReportService { private ApiDefinitionExecResultMapper definitionExecResultMapper; @Resource private UiReportServiceProxy uiReportServiceProxy; + @Resource + private ExtApiScenarioReportResultMapper extApiScenarioReportResultMapper; public void saveResult(ResultDTO dto) { // 报告详情内容 @@ -363,10 +366,30 @@ public class ApiScenarioReportService { if (!StringUtils.equalsAnyIgnoreCase(report.getStatus(), APITestStatus.Rerunning.name())) { report.setEndTime(System.currentTimeMillis()); } - ApiScenarioReportResultExample example = new ApiScenarioReportResultExample(); - example.createCriteria().andReportIdEqualTo(reportId).andStatusEqualTo(ScenarioStatus.Error.name()); - long size = apiScenarioReportResultMapper.countByExample(example); - report.setStatus(size > 0 ? ScenarioStatus.Error.name() : ScenarioStatus.Success.name()); + List statusList = extApiScenarioReportResultMapper.selectDistinctStatusByReportId(reportId); + boolean hasError = false, hasErrorReport = false, hasUnExecute = false, hasOtherStatus = false; + for (String status : statusList) { + if (StringUtils.equalsIgnoreCase(status, ExecuteResult.Error.name())) { + hasError = true; + } else if (StringUtils.equalsIgnoreCase(status, ExecuteResult.errorReportResult.name())) { + hasErrorReport = true; + } else if (StringUtils.equalsIgnoreCase(status, ExecuteResult.unexecute.name())) { + hasUnExecute = true; + } else { + hasOtherStatus = true; + } + } + + if (hasUnExecute && (hasError || hasErrorReport || hasOtherStatus)) { + //只有全部状态都是未执行时,集合报告的状态才可以是未执行 + hasUnExecute = false; + }else if(CollectionUtils.isEmpty(statusList)){ + //查不到任何结果也按照未执行来处理 + hasUnExecute = true; + } + report.setStatus(hasError ? ScenarioStatus.Error.name() : + hasErrorReport ? ExecuteResult.errorReportResult.name() : + hasUnExecute ? ExecuteResult.unexecute.name() : ScenarioStatus.Success.name()); // 更新报告 apiScenarioReportMapper.updateByPrimaryKey(report); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java index f8977c1058..1d55e18d3b 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.java @@ -12,4 +12,5 @@ public interface ExtApiScenarioReportResultMapper { List getReportIds(@Param("ids") List ids); + List selectDistinctStatusByReportId(String reportId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml index ece0d6108e..3afe219bd9 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportResultMapper.xml @@ -30,4 +30,9 @@ #{id} + diff --git a/frontend/src/business/components/task/TaskCenter.vue b/frontend/src/business/components/task/TaskCenter.vue index ff5ef763fe..9096ea2307 100644 --- a/frontend/src/business/components/task/TaskCenter.vue +++ b/frontend/src/business/components/task/TaskCenter.vue @@ -121,6 +121,10 @@ class="ms-task-stopped"> Stopped + + unexecute + {{ $t('error_report_library.option.name') }} @@ -325,7 +329,7 @@ export default { if (status === "waiting" || status === 'stop') { return 0; } - if (status === 'saved' || status === 'completed' || status === 'success' || status === 'error' || status === 'errorreportresult') { + if (status === 'saved' || status === 'completed' || status === 'success' || status === 'error' || status === 'unexecute' || status === 'errorreportresult') { return 100; } }