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 065ab080b0..c671ab8aea 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 @@ -20,7 +20,7 @@ public interface ExtTestPlanApiCaseMapper { List getIdsByPlanId(String planId); - List getNotRelevanceCaseIds(@Param("planId")String planId, @Param("relevanceProjectIds")List relevanceProjectIds); + List getNotRelevanceCaseIds(@Param("planId") String planId, @Param("relevanceProjectIds") List relevanceProjectIds); List getStatusByTestPlanId(String id); @@ -36,14 +36,17 @@ public interface ExtTestPlanApiCaseMapper { List getFailureList(@Param("planId") String planId, @Param("status") String status); - List getFailureListByIds(@Param("ids") Collection caseIdList,@Param("status") String status); + List getFailureListByIds(@Param("ids") Collection caseIdList, @Param("status") String status); List selectPlanIds(); List 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); + + List selectByIdsAndStatusIsNotTrash(@Param("ids") List ids); - Long getLastOrder(@Param("planId")String planId, @Param("baseOrder") Long baseOrder); } 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 c5b5183dd4..fb41d96a3f 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 @@ -3,368 +3,410 @@ - - INSERT INTO test_plan_api_case(id, test_plan_id, api_case_id, environment_id, create_time, update_time, create_user, `order`) - SELECT #{request.id}, #{request.testPlanId}, #{request.apiCaseId}, #{request.environmentId}, #{request.createTime}, #{request.updateTime}, #{request.createUser}, #{request.order} - FROM DUAL - WHERE NOT EXISTS( - SELECT id FROM - test_plan_api_case - WHERE test_plan_id = #{request.testPlanId} and api_case_id = #{request.apiCaseId} - ) - - - - - + SELECT t.* + FROM api_test_case t + INNER JOIN test_plan_api_case tpac ON t.id = tpac.api_case_id + WHERE tpac.id = #{0} + + + + - - + + + and a.projectId = #{request.projectId} + + and t.id in + + #{caseId} + + + + and (c.name like CONCAT('%', #{request.name},'%') + or c.tags like CONCAT('%', #{request.name},'%') + or c.num like CONCAT('%', #{request.name},'%') + ) + + + and a.module_id in + + #{nodeId} + + + + + + + + and c.priority in + + #{value} + + + + and c.create_user_id in + + #{value} + + + + and a.priority in + + #{value} + + + + and a.version_id in + + #{value} + + + + + + + + + + + order by + + + + t.${order.name} ${order.type} + + + create_user_id ${order.type} + + + ${order.name} ${order.type} + + + + - + + + - - + + + + - + - - + + - + - + + - - - and ${versionTable}.version_id = #{request.versionId} - - - and ${versionTable}.ref_id = #{request.refId} - - + + + and ${versionTable}.version_id = #{request.versionId} + + + 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..00ad7b18c6 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.java @@ -0,0 +1,12 @@ +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 { + 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..400cf39c0e --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanApiScenarioMapper.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index fc42413f75..621be021b4 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -35,9 +35,9 @@ import io.metersphere.performance.service.MetricQueryService; import io.metersphere.performance.service.PerformanceReportService; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.service.*; -import io.metersphere.track.factory.ReportComponentFactory; import io.metersphere.track.domain.ReportComponent; import io.metersphere.track.dto.*; +import io.metersphere.track.factory.ReportComponentFactory; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest; @@ -184,6 +184,8 @@ public class TestPlanService { private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper; @Resource private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper; + @Resource + private ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper; public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) { if (getTestPlanByName(testPlan.getName()).size() > 0) { @@ -1924,6 +1926,10 @@ public class TestPlanService { } public String runPlan(TestplanRunRequest testplanRunRequest) { + //检查是否有可以执行的用例 + if (!haveExecCase(testplanRunRequest.getTestPlanId())) { + MSException.throwException(Translator.get("plan_warning")); + } String envType = testplanRunRequest.getEnvironmentType(); Map envMap = testplanRunRequest.getEnvMap(); String environmentGroupId = testplanRunRequest.getEnvironmentGroupId(); @@ -1999,16 +2005,14 @@ public class TestPlanService { if (StringUtils.isBlank(id)) { return false; } - TestPlanApiCaseExample apiCaseExample = new TestPlanApiCaseExample(); - apiCaseExample.createCriteria().andTestPlanIdEqualTo(id); - List testPlanApiCases = testPlanApiCaseMapper.selectByExample(apiCaseExample); + List ids = new ArrayList<>(); + ids.add(id); + List testPlanApiCases = extTestPlanApiCaseMapper.selectByIdsAndStatusIsNotTrash(ids); if (!CollectionUtils.isEmpty(testPlanApiCases)) { return true; } - TestPlanApiScenarioExample apiScenarioExample = new TestPlanApiScenarioExample(); - apiScenarioExample.createCriteria().andTestPlanIdEqualTo(id); - List testPlanApiScenarios = testPlanApiScenarioMapper.selectByExample(apiScenarioExample); + List testPlanApiScenarios = extTestPlanApiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids); if (!CollectionUtils.isEmpty(testPlanApiScenarios)) { return true; } @@ -2153,6 +2157,7 @@ public class TestPlanService { Map executeQueue = new LinkedHashMap<>(); StringBuilder stringBuilder = new StringBuilder(); + StringBuilder haveExecCaseBuilder = new StringBuilder(); for (int i = 0; i < planList.size(); i++) { if (StringUtils.isBlank(planList.get(i).getRunModeConfig())) { StringBuilder append = stringBuilder.append("请保存[").append(planList.get(i).getName()).append("]的运行配置"); @@ -2160,8 +2165,14 @@ public class TestPlanService { append.append("/"); } } + if (!haveExecCase(planList.get(i).getId())) { + haveExecCaseBuilder.append(planList.get(i).getName()).append("; "); + } } + if (StringUtils.isNotEmpty(haveExecCaseBuilder)) { + MSException.throwException(Translator.get("track_test_plan") + ": " + haveExecCaseBuilder.toString() + " :" + Translator.get("plan_warning")); + } if (StringUtils.isNotEmpty(stringBuilder)) { MSException.throwException(stringBuilder.toString()); } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 7f405105bf..830bad0961 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 7f405105bf50af4ae2f1a240059c742f3ac7c729 +Subproject commit 830bad0961b3ec2eaff21e9eac382d16f0521639 diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index f3090e5932..f8aaf7bc80 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -217,8 +217,8 @@ import_xmind_not_found=Test case not found license_valid_license_error=Authorization authentication failed test_review_task_notice=Test review task notice swagger_url_scheduled_import_notification=SwaggerUrl Scheduled import notification -Swagger_parse_error =Swagger parsing failed, please confirm file format is correct! -Swagger_parse_error_with_auth =Swagger parsing failed. Please check whether authentication information is correct or file format is correct! +Swagger_parse_error=Swagger parsing failed, please confirm file format is correct! +Swagger_parse_error_with_auth=Swagger parsing failed. Please check whether authentication information is correct or file format is correct! test_track.length_less_than=The title is too long, the length must be less than # check owner check_owner_project=The current user does not have permission to operate this project @@ -388,3 +388,4 @@ cmdExtractElement=element extraction tcp_mock_not_unique=This tcp port is be used no_tcp_mock_port=No idle tcp port, please contact administrators. name_already_exists_in_module=Name already exists in same module +plan_warning=There is no associated executable use case under the test plan \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index d38894dfd4..9f2aeb2286 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -387,3 +387,4 @@ cmdExtractElement=提取元素信息 tcp_mock_not_unique=该TCP端口号已被使用 no_tcp_mock_port=无可用的TCP端口号,请联系管理员 name_already_exists_in_module=同层级下已经存在 +plan_warning=测试计划下没有关联可以执行的用例 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 3c4a9642e8..8c04a75183 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -386,3 +386,4 @@ cmdExtractElement=提取元素信息 tcp_mock_not_unique=該TCP端口號已被使用 no_tcp_mock_port=無可用的TCP端口號,請聯繫管理員 name_already_exists_in_module=同層級下已存在 +plan_warning=測試計劃下沒有關聯可以執行的用例 \ No newline at end of file diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 20b5563776..12370ba86a 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 20b5563776f552ecd1b84bed3bcf50e5cbcaa9b0 +Subproject commit 12370ba86adfdf31b11a30d48a59c3715490b351