From 1ead202bf719305bca4ff1398a5b66893f30a2ce Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 21 Jul 2022 18:17:33 +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=A4=B1=E8=B4=A5=E9=87=8D=E8=B7=91=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=9F=A5=E8=AF=A2=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015115 --user=赵勇 【测试跟踪】删除测试计划中执行失败的 case 或场景后点失败重跑会报错 https://www.tapd.cn/55049933/s/1206695 --- .../api/exec/api/ApiCaseExecuteService.java | 11 +++++++---- .../mapper/ext/ExtTestPlanApiCaseMapper.java | 3 +++ .../base/mapper/ext/ExtTestPlanApiCaseMapper.xml | 13 +++++++++++++ .../mapper/ext/ExtTestPlanApiScenarioMapper.java | 10 ++++++++++ .../mapper/ext/ExtTestPlanApiScenarioMapper.xml | 16 ++++++++++++++++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.xml diff --git a/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java index 21336f696f..78efcdc319 100644 --- a/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseExecuteService.java @@ -76,8 +76,9 @@ public class ApiCaseExecuteService { * @return */ public List run(BatchRunDefinitionRequest request) { + List responseDTOS = new LinkedList<>(); if (CollectionUtils.isEmpty(request.getPlanIds())) { - return new LinkedList<>(); + return responseDTOS; } if (request.getConfig() == null) { request.setConfig(new RunModeConfigDTO()); @@ -91,13 +92,15 @@ public class ApiCaseExecuteService { example.createCriteria().andIdIn(request.getPlanIds()); example.setOrderByClause("`order` DESC"); List planApiCases = testPlanApiCaseMapper.selectByExample(example); + if (CollectionUtils.isEmpty(planApiCases)) { + return responseDTOS; + } if (StringUtils.isEmpty(request.getTriggerMode())) { request.setTriggerMode(ApiRunMode.API_PLAN.name()); } LoggerUtil.debug("查询到测试计划用例 " + planApiCases.size()); Map executeQueue = request.isRerun() ? request.getExecuteQueue() : new LinkedHashMap<>(); - List responseDTOS = new LinkedList<>(); String status = request.getConfig().getMode().equals(RunModeConstants.SERIAL.toString()) ? APITestStatus.Waiting.name() : APITestStatus.Running.name(); // 查出用例 @@ -358,9 +361,9 @@ public class ApiCaseExecuteService { ApiTestCaseWithBLOBs caseWithBLOBs = caseList.get(i); RunModeConfigDTO config = new RunModeConfigDTO(); - BeanUtils.copyBean(config,request.getConfig()); + BeanUtils.copyBean(config, request.getConfig()); - if(StringUtils.equals(config.getEnvironmentType(), EnvironmentType.JSON.name()) && MapUtils.isEmpty(config.getEnvMap())){ + if (StringUtils.equals(config.getEnvironmentType(), EnvironmentType.JSON.name()) && MapUtils.isEmpty(config.getEnvMap())) { config.setEnvMap(this.getEnvMap(caseWithBLOBs)); } ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.initBase(caseWithBLOBs.getId(), APITestStatus.Running.name(), null, config); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.java index c5edc2290d..57e9640a57 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.java @@ -46,5 +46,8 @@ public interface ExtTestPlanApiCaseMapper { Long getPreOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder); Long getLastOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder); + + List selectByIdsAndStatusIsNotTrash(@Param("ids") List ids); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml index 5c40a93973..2846ff3ab3 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiCaseMapper.xml @@ -385,4 +385,17 @@ and ${versionTable}.ref_id = #{request.refId} + + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.java new file mode 100644 index 0000000000..9cdbe6c840 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.java @@ -0,0 +1,10 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.base.domain.TestPlanApiScenario; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtTestPlanApiScenarioMapper { + public List selectByIdsAndStatusIsNotTrash(@Param("ids") List ids); +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.xml new file mode 100644 index 0000000000..99263c3be9 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.xml @@ -0,0 +1,16 @@ + + + + +