diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.java new file mode 100644 index 0000000000..a75c90e1b8 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.java @@ -0,0 +1,13 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.base.domain.TestPlanUiScenario; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtTestPlanUiScenarioMapper { + + List selectByIdsAndStatusIsNotTrash(@Param("ids") List ids); + + +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.xml new file mode 100644 index 0000000000..e8f90f61fd --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.xml @@ -0,0 +1,19 @@ + + + + + + + \ 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 63b0d26831..e66eaac567 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -189,6 +189,10 @@ public class TestPlanService { private TestPlanUiScenarioMapper testPlanUiScenarioMapper; @Resource private ExtTestPlanUiScenarioCaseMapper extTestPlanUiScenarioCaseMapper; + @Resource + private ExtTestPlanApiScenarioMapper extTestPlanApiScenarioMapper; + @Resource + private ExtTestPlanUiScenarioMapper extTestPlanUiScenarioMapper; public synchronized TestPlan addTestPlan(AddTestPlanRequest testPlan) { if (getTestPlanByName(testPlan.getName()).size() > 0) { @@ -1426,6 +1430,7 @@ public class TestPlanService { * 如果配置了全部用例返回空的数组 * 如果没有,则添加对应的状态 * 都没配置就返回 null + * * @param config * @return */ @@ -2058,6 +2063,10 @@ public class TestPlanService { } public String runPlan(TestplanRunRequest testplanRunRequest) { + //检查测试计划下有没有可以执行的用例; + if (!haveExecCase(testplanRunRequest.getTestPlanId()) || !haveUiCase(testplanRunRequest.getTestPlanId())) { + MSException.throwException(Translator.get("plan_warning")); + } String envType = testplanRunRequest.getEnvironmentType(); Map envMap = testplanRunRequest.getEnvMap(); String environmentGroupId = testplanRunRequest.getEnvironmentGroupId(); @@ -2137,16 +2146,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; } @@ -2295,6 +2302,8 @@ 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("]的运行配置"); @@ -2302,12 +2311,19 @@ public class TestPlanService { append.append("/"); } } + if (!haveExecCase(planList.get(i).getId()) || !haveUiCase(planList.get(i).getId())) { + haveExecCaseBuilder.append(planList.get(i).getName()).append("; "); + } } if (StringUtils.isNotEmpty(stringBuilder)) { MSException.throwException(stringBuilder.toString()); } + if (StringUtils.isNotEmpty(haveExecCaseBuilder)) { + MSException.throwException(Translator.get("track_test_plan") + ": " + haveExecCaseBuilder.toString() + ": " + Translator.get("plan_warning")); + } + for (String id : ids) { TestPlanWithBLOBs testPlan = testPlanMap.get(id); String planReportId = UUID.randomUUID().toString(); @@ -2389,9 +2405,9 @@ public class TestPlanService { return false; } - TestPlanUiScenarioExample uiScenarioExample = new TestPlanUiScenarioExample(); - uiScenarioExample.createCriteria().andTestPlanIdEqualTo(id); - List testPlanUiScenarios = testPlanUiScenarioMapper.selectByExample(uiScenarioExample); + List ids = new ArrayList<>(); + ids.add(id); + List testPlanUiScenarios = extTestPlanUiScenarioMapper.selectByIdsAndStatusIsNotTrash(ids); return !CollectionUtils.isEmpty(testPlanUiScenarios); } } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 0c786599f9..1965e5d82c 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 0c786599f916ed6afc78915f9325457ac52e298b +Subproject commit 1965e5d82cd95cc8ceb8ee5a072acd7380849249 diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index d990876149..10bc0dc2f0 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -220,8 +220,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 @@ -405,3 +405,4 @@ ui_element_already_exists_excel=There are duplicate data in the import file ui_element_already_exists_data=An element with the same name already exists serial=Serial parallel=Parallel +plan_warning=The test plan does not have an associated executable use case diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 01c1e7a2c4..11018d3453 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -404,3 +404,4 @@ ui_element_already_exists_excel=文件中存在多条相同数据 ui_element_already_exists_data=已经存在同名元素 serial=串行 parallel=并行 +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 fb85a84c80..96adb9ba8c 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -403,3 +403,4 @@ ui_element_already_exists_excel=文件中存在多條相同數據 ui_element_already_exists_data=已經存在同名元素 serial=串行 parallel=並行 +plan_warning=測試計劃沒有關聯可執行的用例 diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 0b367ee1d4..311095fddb 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 0b367ee1d426d6bbbfe935d64c5680bcf2db704c +Subproject commit 311095fddb07b11b034b139152a59810cd5ed7d1 diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index d99284e892..6317172319 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -2154,7 +2154,7 @@ export default { batch_copy: '批量复制', batch_add_public: '批量添加到公共用例库', batch_link_demand: '批量关联需求', - public_warning: '未开启公共库用例配置', + public_warning: '未开启公共用例库配置', generate_dependencies: '生成依赖关系', generate_dependencies_warning: '为了更好的体验,建议勾选一百条以下的数据', batch_unlink: '批量取消关联', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index f6f5bb4393..d5119b92aa 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -2149,7 +2149,7 @@ export default { batch_copy: '批量復製', batch_add_public: '批量添加到公共用例庫', batch_link_demand: '批量關聯需求', - public_warning: '未開啟公共庫用例配置', + public_warning: '未開啟公共用例庫配置', generate_dependencies: '生成依賴關系', generate_dependencies_warning: '為了更好的體驗,建議勾選一百條以下的數據', batch_unlink: '批量取消關聯',