From 9e2caa1916f3a9b2935a6d31733fff5e93d54592 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 28 Jul 2022 14:26:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=85=B3=E8=81=94=E5=8F=AF=E6=89=A7=E8=A1=8C=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E6=B2=A1=E6=9C=89=E6=8F=90=E7=A4=BA=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015449 --user=王孝刚 [测试计划]github#16371测试计划里只包含功能用例,在页面无法执行,但是调用API可以执行,且可正常生成报告,报告里无任何信息 https://www.tapd.cn/55049933/s/1214486 --- .../ext/ExtTestPlanUiScenarioMapper.java | 13 +++++++ .../ext/ExtTestPlanUiScenarioMapper.xml | 19 +++++++++++ .../track/service/TestPlanService.java | 34 ++++++++++++++----- backend/src/main/java/io/metersphere/xpack | 2 +- .../resources/i18n/messages_en_US.properties | 5 +-- .../resources/i18n/messages_zh_CN.properties | 1 + .../resources/i18n/messages_zh_TW.properties | 1 + frontend/src/business/components/xpack | 2 +- frontend/src/i18n/zh-CN.js | 2 +- frontend/src/i18n/zh-TW.js | 2 +- 10 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.java create mode 100644 backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanUiScenarioMapper.xml 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: '批量取消關聯',