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

@ -21,7 +21,7 @@ public interface ExtTestPlanApiCaseMapper {
List<String> getIdsByPlanId(String planId); List<String> getIdsByPlanId(String planId);
List<String> getNotRelevanceCaseIds(@Param("planId")String planId, @Param("relevanceProjectIds")List<String> relevanceProjectIds); List<String> getNotRelevanceCaseIds(@Param("planId") String planId, @Param("relevanceProjectIds") List<String> relevanceProjectIds);
List<String> getStatusByTestPlanId(String id); List<String> getStatusByTestPlanId(String id);
@ -37,17 +37,18 @@ public interface ExtTestPlanApiCaseMapper {
List<TestPlanFailureApiDTO> getFailureList(@Param("planId") String planId, @Param("status") String status); List<TestPlanFailureApiDTO> getFailureList(@Param("planId") String planId, @Param("status") String status);
List<TestPlanFailureApiDTO> getFailureListByIds(@Param("ids") Collection<String> caseIdList,@Param("status") String status); List<TestPlanFailureApiDTO> getFailureListByIds(@Param("ids") Collection<String> caseIdList, @Param("status") String status);
List<String> selectPlanIds(); List<String> selectPlanIds();
List<String> getIdsOrderByUpdateTime(@Param("planId") String planId); List<String> getIdsOrderByUpdateTime(@Param("planId") String planId);
Long getPreOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder); Long getPreOrder(@Param("planId") String planId, @Param("baseOrder") Long baseOrder);
Long getLastOrder(@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); List<TestPlanApiCase> selectByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
List<TestPlanApiCase> selectPlanByIdsAndStatusIsNotTrash(@Param("ids") List<String> ids);
} }

View File

@ -388,14 +388,27 @@
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiCase"> <select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiCase">
SELECT SELECT
plan.* plan.*
FROM FROM
test_plan_api_case plan test_plan_api_case plan
INNER JOIN api_test_case api ON plan.api_case_id = api.id INNER JOIN api_test_case api ON plan.api_case_id = api.id
WHERE WHERE
(api.`status` is null OR api.`status` != 'Trash') AND plan.id IN (api.`status` is null OR api.`status` != 'Trash') AND plan.id IN
<foreach collection="ids" item="v" separator="," open="(" close=")"> <foreach collection="ids" item="v" separator="," open="(" close=")">
#{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

@ -3,14 +3,27 @@
<mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiScenarioMapper"> <mapper namespace="io.metersphere.base.mapper.ext.ExtTestPlanApiScenarioMapper">
<select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiScenario"> <select id="selectByIdsAndStatusIsNotTrash" resultType="io.metersphere.base.domain.TestPlanApiScenario">
SELECT SELECT
plan.* plan.*
FROM FROM
test_plan_api_scenario plan test_plan_api_scenario plan
INNER JOIN api_scenario api ON plan.api_scenario_id = api.id INNER JOIN api_scenario api ON plan.api_scenario_id = api.id
WHERE WHERE
(api.`status` is null OR api.`status` != 'Trash') AND plan.id IN (api.`status` is null OR api.`status` != 'Trash') AND plan.id IN
<foreach collection="ids" item="v" separator="," open="(" close=")"> <foreach collection="ids" item="v" separator="," open="(" close=")">
#{v} #{v}
</foreach> </foreach>
</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> </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);
} }
} }