perf(测试跟踪): 优化测试计划关联功能用例性能
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001018291 --user=郭雨琦
This commit is contained in:
parent
2161159627
commit
e3531d5ee2
|
@ -10,7 +10,6 @@ import io.metersphere.base.mapper.ext.ExtTestPlanReportMapper;
|
||||||
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper;
|
||||||
import io.metersphere.commons.constants.*;
|
import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
import io.metersphere.constants.RunModeConstants;
|
import io.metersphere.constants.RunModeConstants;
|
||||||
import io.metersphere.dto.*;
|
import io.metersphere.dto.*;
|
||||||
|
@ -574,22 +573,38 @@ public class TestPlanService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void caseTestRelevance(PlanCaseRelevanceRequest request, List<String> testCaseIds) {
|
public void caseTestRelevance(PlanCaseRelevanceRequest request, List<String> testCaseIds) {
|
||||||
|
|
||||||
//同步添加关联的接口和测试用例
|
//同步添加关联的接口和测试用例
|
||||||
if (request.getChecked()) {
|
if (!request.getChecked()) {
|
||||||
if (!testCaseIds.isEmpty()) {
|
return;
|
||||||
testCaseIds.forEach(caseId -> {
|
}
|
||||||
List<TestCaseTest> list = new ArrayList<>();
|
if (CollectionUtils.isEmpty(testCaseIds)) {
|
||||||
TestCaseTestExample examp = new TestCaseTestExample();
|
return;
|
||||||
examp.createCriteria().andTestCaseIdEqualTo(caseId);
|
}
|
||||||
if (testCaseTestMapper.countByExample(examp) > 0) {
|
List<TestCaseTest> list;
|
||||||
list = testCaseTestMapper.selectByExample(examp);
|
TestCaseTestExample exam = new TestCaseTestExample();
|
||||||
|
exam.createCriteria().andTestCaseIdIn(testCaseIds);
|
||||||
|
list = testCaseTestMapper.selectByExample(exam);
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> apiCaseIds = new ArrayList<>();
|
List<String> apiCaseIds = new ArrayList<>();
|
||||||
List<String> scenarioIds = new ArrayList<>();
|
List<String> scenarioIds = new ArrayList<>();
|
||||||
List<String> performanceIds = new ArrayList<>();
|
List<String> performanceIds = new ArrayList<>();
|
||||||
|
buildCaseIdList(list, apiCaseIds, scenarioIds, performanceIds);
|
||||||
|
startRelevance(request, apiCaseIds, scenarioIds, performanceIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startRelevance(PlanCaseRelevanceRequest request, List<String> apiCaseIds, List<String> scenarioIds, List<String> performanceIds) {
|
||||||
|
try {
|
||||||
|
relevanceTestCaseTest(apiCaseIds, request.getPlanId(), planTestPlanApiCaseService::relevanceByTestIds);
|
||||||
|
relevanceTestCaseTest(scenarioIds, request.getPlanId(), planTestPlanScenarioCaseService::relevanceByTestIds);
|
||||||
|
relevanceTestCaseTest(performanceIds, request.getPlanId(), planTestPlanLoadCaseService::relevanceByTestIds);
|
||||||
|
} catch (MSException e) {
|
||||||
|
LogUtil.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void buildCaseIdList(List<TestCaseTest> list, List<String> apiCaseIds, List<String> scenarioIds, List<String> performanceIds) {
|
||||||
for (TestCaseTest l : list) {
|
for (TestCaseTest l : list) {
|
||||||
if (StringUtils.equals(l.getTestType(), TestCaseTestStatus.performance.name())) {
|
if (StringUtils.equals(l.getTestType(), TestCaseTestStatus.performance.name())) {
|
||||||
performanceIds.add(l.getTestId());
|
performanceIds.add(l.getTestId());
|
||||||
|
@ -601,16 +616,6 @@ public class TestPlanService {
|
||||||
scenarioIds.add(l.getTestId());
|
scenarioIds.add(l.getTestId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
relevanceTestCaseTest(apiCaseIds, request.getPlanId(), planTestPlanApiCaseService::relevanceByTestIds);
|
|
||||||
relevanceTestCaseTest(scenarioIds, request.getPlanId(), planTestPlanScenarioCaseService::relevanceByTestIds);
|
|
||||||
relevanceTestCaseTest(performanceIds, request.getPlanId(), planTestPlanLoadCaseService::relevanceByTestIds);
|
|
||||||
} catch (MSException e) {
|
|
||||||
LogUtil.error(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void relevanceTestCaseTest(List<String> ids, String planId, BiConsumer<List<String>, String> relevanceByTestIds) {
|
public void relevanceTestCaseTest(List<String> ids, String planId, BiConsumer<List<String>, String> relevanceByTestIds) {
|
||||||
|
|
Loading…
Reference in New Issue