fix(接口测试): 修复失败重跑资源查询错误问题
--bug=1015115 --user=赵勇 【测试跟踪】删除测试计划中执行失败的 case 或场景后点失败重跑会报错 https://www.tapd.cn/55049933/s/1206695
This commit is contained in:
parent
4d5f4f192a
commit
1ead202bf7
|
@ -76,8 +76,9 @@ public class ApiCaseExecuteService {
|
|||
* @return
|
||||
*/
|
||||
public List<MsExecResponseDTO> run(BatchRunDefinitionRequest request) {
|
||||
List<MsExecResponseDTO> 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<TestPlanApiCase> 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<String, ApiDefinitionExecResultWithBLOBs> executeQueue = request.isRerun() ? request.getExecuteQueue() : new LinkedHashMap<>();
|
||||
List<MsExecResponseDTO> 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);
|
||||
|
|
|
@ -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<TestPlanApiCase> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -385,4 +385,17 @@
|
|||
and ${versionTable}.ref_id = #{request.refId}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiCase">
|
||||
SELECT
|
||||
plan.*
|
||||
FROM
|
||||
test_plan_api_case plan
|
||||
INNER JOIN api_test_case api ON plan.api_case_id = api.id
|
||||
WHERE
|
||||
(api.`status` is null OR api.`status` != 'Trash') AND plan.id IN
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -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<TestPlanApiScenario> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiScenarioMapper">
|
||||
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiScenario">
|
||||
SELECT
|
||||
plan.*
|
||||
FROM
|
||||
test_plan_api_scenario plan
|
||||
INNER JOIN api_scenario api ON plan.api_scenario_id = api.id
|
||||
WHERE
|
||||
(api.`status` is null OR api.`status` != 'Trash') AND plan.id IN
|
||||
<foreach collection="ids" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue