fix(测试跟踪): 覆盖用例中未统计关联的UI用例
--bug=1024707 --user=宋昌昌 【测试跟踪】首页-用例责任人分布中-已关联功能用例数量 统计中,未统计关联UI用例 https://www.tapd.cn/55049933/s/1353724
This commit is contained in:
parent
6381ad0265
commit
d3f582e2ea
|
@ -681,7 +681,7 @@
|
||||||
and test_case.project_id = #{request.projectId}
|
and test_case.project_id = #{request.projectId}
|
||||||
</if>
|
</if>
|
||||||
<include refid="filters"/>
|
<include refid="filters"/>
|
||||||
<if test="request.caseCoverage == 'uncoverage' ">
|
<if test="request.caseCoverage == 'uncoverage'">
|
||||||
and test_case.id not in (
|
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
|
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')
|
api_test_case WHERE `STATUS` is null or status != 'Trash')
|
||||||
|
@ -691,9 +691,24 @@
|
||||||
UNION
|
UNION
|
||||||
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
|
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
|
||||||
api_scenario WHERE `STATUS` != 'Trash')
|
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')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="!request.queryUi and request.caseCoverage == 'coverage'">
|
||||||
|
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')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.caseCoverage == 'coverage' ">
|
<if test="request.queryUi and request.caseCoverage == 'coverage'">
|
||||||
and test_case.id in (
|
and test_case.id in (
|
||||||
SELECT test_case_id FROM test_case_test WHERE test_type = 'testCase' and test_id IN (select id FROM
|
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')
|
api_test_case WHERE `STATUS` is null or status != 'Trash')
|
||||||
|
@ -703,6 +718,9 @@
|
||||||
UNION
|
UNION
|
||||||
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
|
SELECT test_case_id FROM test_case_test WHERE test_type = 'automation' and test_id IN (select id FROM
|
||||||
api_scenario WHERE `STATUS` != 'Trash')
|
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')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
<include refid="queryVersionCondition">
|
<include refid="queryVersionCondition">
|
||||||
|
@ -863,13 +881,11 @@
|
||||||
FROM test_case_test
|
FROM test_case_test
|
||||||
WHERE test_type = 'automation'
|
WHERE test_type = 'automation'
|
||||||
and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash')
|
and test_id IN (select id FROM api_scenario WHERE `STATUS` != 'Trash')
|
||||||
<if test="queryUI">
|
|
||||||
UNION
|
UNION
|
||||||
SELECT test_case_id, test_id, test_type
|
SELECT test_case_id, test_id, test_type
|
||||||
FROM test_case_test
|
FROM test_case_test
|
||||||
WHERE test_type = 'uiAutomation'
|
WHERE test_type = 'uiAutomation'
|
||||||
and test_id IN (select id FROM ui_scenario WHERE `STATUS` != 'Trash')
|
and test_id IN (select id FROM ui_scenario WHERE `STATUS` != 'Trash')
|
||||||
</if>
|
|
||||||
)
|
)
|
||||||
test_case_test
|
test_case_test
|
||||||
ON test_case.id = test_case_test.test_case_id
|
ON test_case.id = test_case_test.test_case_id
|
||||||
|
|
|
@ -9,10 +9,12 @@ import io.metersphere.commons.utils.Pager;
|
||||||
import io.metersphere.dto.*;
|
import io.metersphere.dto.*;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.plan.dto.ChartsData;
|
import io.metersphere.plan.dto.ChartsData;
|
||||||
|
import io.metersphere.request.testcase.TrackCount;
|
||||||
import io.metersphere.service.TestCaseService;
|
import io.metersphere.service.TestCaseService;
|
||||||
import io.metersphere.service.TrackService;
|
import io.metersphere.service.TrackService;
|
||||||
import io.metersphere.utils.DiscoveryUtil;
|
import io.metersphere.utils.DiscoveryUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
@ -105,7 +107,15 @@ public class TrackController {
|
||||||
|
|
||||||
boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST);
|
boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST);
|
||||||
List<TrackCountResult> relevanceResults = trackService.countRelevance(projectId, queryUi);
|
List<TrackCountResult> relevanceResults = trackService.countRelevance(projectId, queryUi);
|
||||||
statistics.countRelevance(relevanceResults);
|
long uiCountNum = 0L;
|
||||||
|
if (!queryUi) {
|
||||||
|
List<TrackCountResult> 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);
|
long size = trackService.countRelevanceCreatedThisWeek(projectId);
|
||||||
statistics.setThisWeekAddedCount(size);
|
statistics.setThisWeekAddedCount(size);
|
||||||
|
@ -114,7 +124,7 @@ public class TrackController {
|
||||||
long total = list.size();
|
long total = list.size();
|
||||||
int coverage = trackService.countCoverage(projectId, queryUi);
|
int coverage = trackService.countCoverage(projectId, queryUi);
|
||||||
statistics.setCoverageCount(coverage);
|
statistics.setCoverageCount(coverage);
|
||||||
statistics.setUncoverageCount(total - coverage);
|
statistics.setUncoverageCount(total - coverage - uiCountNum);
|
||||||
|
|
||||||
if (total != 0) {
|
if (total != 0) {
|
||||||
float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total;
|
float coverageRageNumber = (float) statistics.getCoverageCount() * 100 / total;
|
||||||
|
|
|
@ -163,7 +163,7 @@ public class TrackStatisticsDTO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void countRelevance(List<TrackCountResult> relevanceResults) {
|
public void countRelevance(List<TrackCountResult> relevanceResults, boolean queryUI) {
|
||||||
Map<String, Integer> chartData = new HashMap<>();
|
Map<String, Integer> chartData = new HashMap<>();
|
||||||
for (TrackCountResult countResult : relevanceResults) {
|
for (TrackCountResult countResult : relevanceResults) {
|
||||||
if (StringUtils.equalsIgnoreCase(TrackCount.TESTCASE, countResult.getGroupField())) {
|
if (StringUtils.equalsIgnoreCase(TrackCount.TESTCASE, countResult.getGroupField())) {
|
||||||
|
@ -193,13 +193,15 @@ public class TrackStatisticsDTO {
|
||||||
chartData.put(Translator.get("scenario_case"), count);
|
chartData.put(Translator.get("scenario_case"), count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.equalsIgnoreCase(TrackCount.UI_AUTOMATION, countResult.getGroupField())) {
|
if (queryUI) {
|
||||||
Integer count = chartData.get(Translator.get("ui_scenario_case"));
|
if (StringUtils.equalsIgnoreCase(TrackCount.UI_AUTOMATION, countResult.getGroupField())) {
|
||||||
if (count == null) {
|
Integer count = chartData.get(Translator.get("ui_scenario_case"));
|
||||||
chartData.put(Translator.get("ui_scenario_case"), (int) countResult.getCountNumber());
|
if (count == null) {
|
||||||
} else {
|
chartData.put(Translator.get("ui_scenario_case"), (int) countResult.getCountNumber());
|
||||||
count += (int) countResult.getCountNumber();
|
} else {
|
||||||
chartData.put(Translator.get("ui_scenario_case"), count);
|
count += (int) countResult.getCountNumber();
|
||||||
|
chartData.put(Translator.get("ui_scenario_case"), count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.allRelevanceCaseCount += countResult.getCountNumber();
|
this.allRelevanceCaseCount += countResult.getCountNumber();
|
||||||
|
@ -210,6 +212,9 @@ public class TrackStatisticsDTO {
|
||||||
chartData.put(Translator.get("api_case"), 0);
|
chartData.put(Translator.get("api_case"), 0);
|
||||||
chartData.put(Translator.get("performance_case"), 0);
|
chartData.put(Translator.get("performance_case"), 0);
|
||||||
chartData.put(Translator.get("scenario_case"), 0);
|
chartData.put(Translator.get("scenario_case"), 0);
|
||||||
|
if (queryUI) {
|
||||||
|
chartData.put(Translator.get("ui_scenario_case"), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.chartData = chartData;
|
this.chartData = chartData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,4 +63,9 @@ public class QueryTestCaseRequest extends BaseQueryRequest {
|
||||||
private Boolean toBeUpdated;
|
private Boolean toBeUpdated;
|
||||||
private String apiCoverage;
|
private String apiCoverage;
|
||||||
private String scenarioCoverage;
|
private String scenarioCoverage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否查询UI
|
||||||
|
*/
|
||||||
|
private boolean queryUi;
|
||||||
}
|
}
|
||||||
|
|
|
@ -792,6 +792,8 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) {
|
public List<TestCaseDTO> listTestCase(QueryTestCaseRequest request, boolean isSampleInfo) {
|
||||||
|
boolean queryUi = DiscoveryUtil.hasService(MicroServiceName.UI_TEST);
|
||||||
|
request.setQueryUi(queryUi);
|
||||||
this.initRequest(request, true);
|
this.initRequest(request, true);
|
||||||
setDefaultOrder(request);
|
setDefaultOrder(request);
|
||||||
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
ServiceUtils.setBaseQueryRequestCustomMultipleFields(request);
|
||||||
|
|
Loading…
Reference in New Issue