feat(测试计划): 计划统计添加通过阈值

This commit is contained in:
song-cc-rock 2024-05-14 20:25:14 +08:00 committed by 刘瑞斌
parent 5f2accc982
commit 0a23c86363
2 changed files with 13 additions and 1 deletions

View File

@ -1,8 +1,11 @@
package io.metersphere.plan.service;
import io.metersphere.plan.domain.TestPlanConfig;
import io.metersphere.plan.domain.TestPlanConfigExample;
import io.metersphere.plan.domain.TestPlanFunctionalCase;
import io.metersphere.plan.dto.response.TestPlanStatisticsResponse;
import io.metersphere.plan.mapper.ExtTestPlanFunctionalCaseMapper;
import io.metersphere.plan.mapper.TestPlanConfigMapper;
import io.metersphere.sdk.constants.FunctionalCaseExecuteResult;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
@ -18,6 +21,8 @@ import java.util.stream.Collectors;
@Service
public class TestPlanStatisticsService {
@Resource
private TestPlanConfigMapper testPlanConfigMapper;
@Resource
private ExtTestPlanFunctionalCaseMapper extTestPlanFunctionalCaseMapper;
@ -65,6 +70,11 @@ public class TestPlanStatisticsService {
rateFormat.setMinimumFractionDigits(2);
rateFormat.setMaximumFractionDigits(2);
// 计划的更多配置
TestPlanConfigExample example = new TestPlanConfigExample();
example.createCriteria().andTestPlanIdIn(planIds);
List<TestPlanConfig> testPlanConfigList = testPlanConfigMapper.selectByExample(example);
Map<String, TestPlanConfig> planConfigMap = testPlanConfigList.stream().collect(Collectors.toMap(TestPlanConfig::getTestPlanId, p -> p));
// 计划-功能用例的关联数据
List<TestPlanFunctionalCase> planFunctionalCases = extTestPlanFunctionalCaseMapper.getPlanFunctionalCaseByIds(planIds);
Map<String, List<TestPlanFunctionalCase>> planFunctionalCaseMap = planFunctionalCases.stream().collect(Collectors.groupingBy(TestPlanFunctionalCase::getTestPlanId));
@ -72,6 +82,7 @@ public class TestPlanStatisticsService {
planIds.forEach(planId -> {
TestPlanStatisticsResponse statisticsResponse = new TestPlanStatisticsResponse();
statisticsResponse.setId(planId);
statisticsResponse.setPassThreshold(planConfigMap.get(planId).getPassThreshold());
int success = 0, error = 0, fakeError = 0, block = 0, pending = 0;
// 功能用例统计开始
List<TestPlanFunctionalCase> functionalCases = planFunctionalCaseMap.get(planId);

View File

@ -33,7 +33,8 @@ VALUES
INSERT INTO `test_plan_config`(`test_plan_id`, `automatic_status_update`, `repeat_case`, `pass_threshold`, `test_planning`)
VALUES
('wx_test_plan_id_1', b'0', b'0', 100, b'0'),
('wx_test_plan_id_4', b'0', b'0', 100, b'0');
('wx_test_plan_id_4', b'0', b'0', 100, b'0'),
('wx_test_plan_id_7', b'0', b'0', 100, b'0');
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time, module_setting)