fix(测试跟踪): 修复测试计划运行检查是否有可用行用例的缺陷 (#16498)

Co-authored-by: wxg0103 <727495428@qq.com>
This commit is contained in:
MeterSphere Bot 2022-07-29 17:56:53 +08:00 committed by GitHub
parent 18f6f0c480
commit 4afde03346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 21 deletions

View File

@ -49,5 +49,6 @@ public interface ExtTestPlanApiCaseMapper {
List<TestPlanApiCase> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids); List<TestPlanApiCase> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
List<TestPlanApiCase> selectPlanByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
} }

View File

@ -398,4 +398,17 @@
#{v} #{v}
</foreach> </foreach>
</select> </select>
<select id="selectPlanByIdsAndStatusIsNotTrash" 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.test_plan_id IN
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</select>
</mapper> </mapper>

View File

@ -7,4 +7,7 @@ import java.util.List;
public interface ExtTestPlanApiScenarioMapper { public interface ExtTestPlanApiScenarioMapper {
public List<TestPlanApiScenario> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids); public List<TestPlanApiScenario> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
List<TestPlanApiScenario> selectPlanByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
} }

View File

@ -13,4 +13,17 @@
#{v} #{v}
</foreach> </foreach>
</select> </select>
<select id="selectPlanByIdsAndStatusIsNotTrash"
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.test_plan_id IN
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</select>
</mapper> </mapper>

View File

@ -7,7 +7,7 @@ import java.util.List;
public interface ExtTestPlanUiScenarioMapper { public interface ExtTestPlanUiScenarioMapper {
List<TestPlanUiScenario> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids); List<TestPlanUiScenario> selectPlanByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
} }

View File

@ -3,14 +3,14 @@
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanUiScenarioMapper"> <mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanUiScenarioMapper">
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanUiScenario"> <select id="selectPlanByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanUiScenario">
SELECT SELECT
plan.* plan.*
FROM FROM
test_plan_ui_scenario plan test_plan_ui_scenario plan
INNER JOIN ui_scenario ui ON plan.ui_scenario_id = ui.id INNER JOIN ui_scenario ui ON plan.ui_scenario_id = ui.id
WHERE WHERE
(ui.`status` is null OR ui.`status` != 'Trash') AND plan.id IN (ui.`status` is null OR ui.`status` != 'Trash') AND plan.test_plan_id IN
<foreach collection="ids" item="v" separator="," open="(" close=")"> <foreach collection="ids" item="v" separator="," open="(" close=")">
#{v} #{v}
</foreach> </foreach>

View File

@ -2148,12 +2148,12 @@ public class TestPlanService {
} }
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
ids.add(id); ids.add(id);
List<TestPlanApiCase> testPlanApiCases = extTestPlanApiCaseMapper.selectByIdsAndStatusIsNotTrash(ids); List<TestPlanApiCase> testPlanApiCases = extTestPlanApiCaseMapper.selectPlanByIdsAndStatusIsNotTrash(ids);
if (!CollectionUtils.isEmpty(testPlanApiCases)) { if (!CollectionUtils.isEmpty(testPlanApiCases)) {
return true; return true;
} }
List<TestPlanApiScenario> testPlanApiScenarios = extTestPlanApiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids); List<TestPlanApiScenario> testPlanApiScenarios = extTestPlanApiScenarioMapper.selectPlanByIdsAndStatusIsNotTrash(ids);
if (!CollectionUtils.isEmpty(testPlanApiScenarios)) { if (!CollectionUtils.isEmpty(testPlanApiScenarios)) {
return true; return true;
} }
@ -2407,7 +2407,7 @@ public class TestPlanService {
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
ids.add(id); ids.add(id);
List<TestPlanUiScenario> testPlanUiScenarios = extTestPlanUiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids); List<TestPlanUiScenario> testPlanUiScenarios = extTestPlanUiScenarioMapper.selectPlanByIdsAndStatusIsNotTrash(ids);
return !CollectionUtils.isEmpty(testPlanUiScenarios); return !CollectionUtils.isEmpty(testPlanUiScenarios);
} }
} }