From d3f582e2ea6bd6b34627d0527dc6c1f6dae71e17 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Tue, 21 Mar 2023 15:10:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=94=A8=E4=BE=8B=E4=B8=AD=E6=9C=AA=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=85=B3=E8=81=94=E7=9A=84UI=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024707 --user=宋昌昌 【测试跟踪】首页-用例责任人分布中-已关联功能用例数量 统计中,未统计关联UI用例 https://www.tapd.cn/55049933/s/1353724 --- .../base/mapper/ext/ExtTestCaseMapper.xml | 24 +++++++++++++++---- .../controller/TrackController.java | 14 +++++++++-- .../metersphere/dto/TrackStatisticsDTO.java | 21 +++++++++------- .../testcase/QueryTestCaseRequest.java | 5 ++++ .../metersphere/service/TestCaseService.java | 2 ++ 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 92d7c79ebf..007c129b2f 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -681,7 +681,7 @@ and test_case.project_id = #{request.projectId} - + and test_case.id not in ( SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM api_test_case WHERE `STATUS` is null or status != 'Trash') @@ -691,9 +691,24 @@ UNION SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash') + UNION + SELECT test_case_id FROM test_case_test WHERE test_type = 'uiAutomation' and test_id IN (select id FROM + ui_scenario WHERE `STATUS` != 'Trash') + ) + + + and test_case.id in ( + SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM + api_test_case WHERE `STATUS` is null or status != 'Trash') + UNION + SELECT test_case_id FROM test_case_test WHERE test_type = 'performance' and test_id IN (select id from + load_test) + UNION + SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM + api_scenario WHERE `STATUS` != 'Trash') ) - + and test_case.id in ( SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM api_test_case WHERE `STATUS` is null or status != 'Trash') @@ -703,6 +718,9 @@ UNION SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash') + UNION + SELECT test_case_id FROM test_case_test WHERE test_type = 'uiAutomation' and test_id IN (select id FROM + ui_scenario WHERE `STATUS` != 'Trash') ) @@ -863,13 +881,11 @@ FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash') - UNION SELECT test_case_id, test_id, test_type FROM test_case_test WHERE test_type = 'uiAutomation' and test_id IN (select id FROM ui_scenario WHERE `STATUS` != 'Trash') - ) test_case_test ON test_case.id = test_case_test.test_case_id diff --git a/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java b/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java index 199a59bfb4..004586f4e5 100644 --- a/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java +++ b/test-track/backend/src/main/java/io/metersphere/controller/TrackController.java @@ -9,10 +9,12 @@ import io.metersphere.commons.utils.Pager; import io.metersphere.dto.*; import io.metersphere.i18n.Translator; import io.metersphere.plan.dto.ChartsData; +import io.metersphere.request.testcase.TrackCount; import io.metersphere.service.TestCaseService; import io.metersphere.service.TrackService; import io.metersphere.utils.DiscoveryUtil; import jakarta.annotation.Resource; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -105,7 +107,15 @@ public class TrackController { boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST); List relevanceResults = trackService.countRelevance(projectId, queryUi); - statistics.countRelevance(relevanceResults); + long uiCountNum = 0L; + if (!queryUi) { + List uiGroup = + relevanceResults.stream().filter(relevanceResult -> StringUtils.equals(relevanceResult.getGroupField(), TrackCount.UI_AUTOMATION)).toList(); + if (CollectionUtils.isNotEmpty(uiGroup)) { + uiCountNum = uiGroup.get(0).getCountNumber(); + } + } + statistics.countRelevance(relevanceResults, queryUi); long size = trackService.countRelevanceCreatedThisWeek(projectId); statistics.setThisWeekAddedCount(size); @@ -114,7 +124,7 @@ public class TrackController { long total = list.size(); int coverage = trackService.countCoverage(projectId, queryUi); statistics.setCoverageCount(coverage); - statistics.setUncoverageCount(total - coverage); + statistics.setUncoverageCount(total - coverage - uiCountNum); if (total != 0) { float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total; diff --git a/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java b/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java index 29d5869841..296b43e578 100644 --- a/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java +++ b/test-track/backend/src/main/java/io/metersphere/dto/TrackStatisticsDTO.java @@ -163,7 +163,7 @@ public class TrackStatisticsDTO { } } - public void countRelevance(List relevanceResults) { + public void countRelevance(List relevanceResults, boolean queryUI) { Map chartData = new HashMap<>(); for (TrackCountResult countResult : relevanceResults) { if (StringUtils.equalsIgnoreCase(TrackCount.TESTCASE, countResult.getGroupField())) { @@ -193,13 +193,15 @@ public class TrackStatisticsDTO { chartData.put(Translator.get("scenario_case"), count); } } - if (StringUtils.equalsIgnoreCase(TrackCount.UI_AUTOMATION, countResult.getGroupField())) { - Integer count = chartData.get(Translator.get("ui_scenario_case")); - if (count == null) { - chartData.put(Translator.get("ui_scenario_case"), (int) countResult.getCountNumber()); - } else { - count += (int) countResult.getCountNumber(); - chartData.put(Translator.get("ui_scenario_case"), count); + if (queryUI) { + if (StringUtils.equalsIgnoreCase(TrackCount.UI_AUTOMATION, countResult.getGroupField())) { + Integer count = chartData.get(Translator.get("ui_scenario_case")); + if (count == null) { + chartData.put(Translator.get("ui_scenario_case"), (int) countResult.getCountNumber()); + } else { + count += (int) countResult.getCountNumber(); + chartData.put(Translator.get("ui_scenario_case"), count); + } } } this.allRelevanceCaseCount += countResult.getCountNumber(); @@ -210,6 +212,9 @@ public class TrackStatisticsDTO { chartData.put(Translator.get("api_case"), 0); chartData.put(Translator.get("performance_case"), 0); chartData.put(Translator.get("scenario_case"), 0); + if (queryUI) { + chartData.put(Translator.get("ui_scenario_case"), 0); + } } this.chartData = chartData; } diff --git a/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java b/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java index 66cd3acfde..eac4f6e564 100644 --- a/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java +++ b/test-track/backend/src/main/java/io/metersphere/request/testcase/QueryTestCaseRequest.java @@ -63,4 +63,9 @@ public class QueryTestCaseRequest extends BaseQueryRequest { private Boolean toBeUpdated; private String apiCoverage; private String scenarioCoverage; + + /** + * 是否查询UI + */ + private boolean queryUi; } diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index 8535a83bce..be12fc4adf 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -792,6 +792,8 @@ public class TestCaseService { } public List listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) { + boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST); + request.setQueryUi(queryUi); this.initRequest(request, true); setDefaultOrder(request); ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);