feat(测试计划): 测试计划增加通过和未通过的字段显示
This commit is contained in:
parent
06a03c29e7
commit
aee08fd888
|
@ -33,6 +33,9 @@ public class TestPlanStatisticsResponse {
|
|||
@JsonSerialize(using = CustomRateSerializer.class)
|
||||
private Double executeRate;
|
||||
|
||||
@Schema(description = "测试计划是否通过")
|
||||
private boolean isPass = false;
|
||||
|
||||
/**
|
||||
* 执行进度中的用例数量统计
|
||||
*/
|
||||
|
@ -88,6 +91,10 @@ public class TestPlanStatisticsResponse {
|
|||
this.caseTotal = this.functionalCaseCount + this.apiCaseCount + this.apiScenarioCount;
|
||||
}
|
||||
|
||||
public void calculateTestPlanIsPass() {
|
||||
this.isPass = this.passRate >= this.passThreshold;
|
||||
}
|
||||
|
||||
public void calculatePassRate() {
|
||||
this.passRate = RateCalculateUtils.divWithPrecision(this.successCount, this.caseTotal, 2);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import io.metersphere.system.mapper.ScheduleMapper;
|
|||
import io.metersphere.system.utils.ScheduleUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -23,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -140,8 +142,12 @@ public class TestPlanStatisticsService {
|
|||
List<TestPlanStatisticsResponse> childrenResponse = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
List<String> childStatus = new ArrayList<>();
|
||||
AtomicBoolean hasNotPassedChild = new AtomicBoolean(false);
|
||||
children.forEach(child -> {
|
||||
TestPlanStatisticsResponse childResponse = this.genTestPlanStatisticsResponse(child, planConfigMap, planFunctionalCaseMap, planApiCaseMap, planApiScenarioMap, scheduleMap);
|
||||
if (BooleanUtils.isFalse(childResponse.isPass())) {
|
||||
hasNotPassedChild.set(true);
|
||||
}
|
||||
childResponse.setStatus(child.getStatus());
|
||||
|
||||
childResponse.calculateStatus();
|
||||
|
@ -156,11 +162,15 @@ public class TestPlanStatisticsService {
|
|||
if (!StringUtils.equalsIgnoreCase(rootResponse.getStatus(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) {
|
||||
rootResponse.setStatus(testPlanBaseUtilsService.calculateStatusByChildren(childStatus));
|
||||
}
|
||||
if (!hasNotPassedChild.get()) {
|
||||
rootResponse.setPass(true);
|
||||
}
|
||||
} else {
|
||||
rootResponse.calculateCaseTotal();
|
||||
rootResponse.calculatePassRate();
|
||||
rootResponse.calculateExecuteRate();
|
||||
rootResponse.calculateStatus();
|
||||
rootResponse.calculateTestPlanIsPass();
|
||||
}
|
||||
returnResponse.add(rootResponse);
|
||||
returnResponse.addAll(childrenResponse);
|
||||
|
@ -220,6 +230,7 @@ public class TestPlanStatisticsService {
|
|||
statisticsResponse.calculateCaseTotal();
|
||||
statisticsResponse.calculatePassRate();
|
||||
statisticsResponse.calculateExecuteRate();
|
||||
statisticsResponse.calculateTestPlanIsPass();
|
||||
}
|
||||
//定时任务
|
||||
if (scheduleMap.containsKey(planId)) {
|
||||
|
|
|
@ -1721,6 +1721,18 @@ public class TestPlanControllerTests extends BaseTest {
|
|||
TestPlanStatisticsResponse.class);
|
||||
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||
|
||||
|
||||
statisticsResponses = JSON.parseArray(
|
||||
JSON.toJSONString(
|
||||
JSON.parseObject(
|
||||
this.requestPostAndReturn(URL_POST_TEST_PLAN_STATISTICS, new ArrayList<>() {{
|
||||
this.add(testPlanId6);
|
||||
this.add(groupTestPlanId46);
|
||||
}})
|
||||
.getResponse().getContentAsString(), ResultHolder.class).getData()),
|
||||
TestPlanStatisticsResponse.class);
|
||||
Assertions.assertTrue(statisticsResponses.size() > 1);
|
||||
|
||||
//增加日志检查
|
||||
LOG_CHECK_LIST.add(
|
||||
new CheckLogModel(groupTestPlanId7, OperationLogType.UPDATE, null)
|
||||
|
|
Loading…
Reference in New Issue