fix(测试跟踪): 测试计划进度显示不准确

--bug=1018889 --user=陈建星 【测试跟踪】测试计划列表,测试进度显示不对 https://www.tapd.cn/55049933/s/1285731
This commit is contained in:
chenjianxing 2022-11-01 19:05:29 +08:00 committed by jianxing
parent e324b68f64
commit dbb1d3d259
1 changed files with 4 additions and 13 deletions

View File

@ -364,15 +364,7 @@ public class TestPlanService {
} }
if (serviceIdSet.contains(MicroServiceName.UI_TEST)) { if (serviceIdSet.contains(MicroServiceName.UI_TEST)) {
List<String> uiScenarioExecResults = calcExecResultStatus(testPlan.getId(), testPlan, planTestPlanUiScenarioCaseService::getExecResultByPlanId); calcExecResultStatus(testPlan.getId(), testPlan, planTestPlanUiScenarioCaseService::getExecResultByPlanId);
uiScenarioExecResults.forEach(item -> {
if (StringUtils.isNotBlank(item)) {
testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equals(item, "Success")) {
testPlan.setPassed(testPlan.getPassed() + 1);
}
}
});
} }
testPlan.setPassRate(MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTotal())); testPlan.setPassRate(MathUtils.getPercentWithDecimal(testPlan.getTested() == 0 ? 0 : testPlan.getPassed() * 1.0 / testPlan.getTotal()));
@ -385,13 +377,13 @@ public class TestPlanService {
* @param planId * @param planId
* @return * @return
*/ */
List<String> calcExecResultStatus(String planId, TestPlanDTOWithMetric testPlan, Function<String, List<String>> getResultFunc) { void calcExecResultStatus(String planId, TestPlanDTOWithMetric testPlan, Function<String, List<String>> getResultFunc) {
try { try {
List<String> execResults = getResultFunc.apply(planId); List<String> execResults = getResultFunc.apply(planId);
execResults.forEach(item -> { execResults.forEach(item -> {
if (StringUtils.isNotBlank(item)) { if (StringUtils.isNotBlank(item) && !StringUtils.equalsIgnoreCase("UnExecute", item)) {
testPlan.setTested(testPlan.getTested() + 1); testPlan.setTested(testPlan.getTested() + 1);
if (StringUtils.equalsIgnoreCase(item, "Success")) { if (StringUtils.equalsIgnoreCase(item, APITestStatus.Success.name())) {
testPlan.setPassed(testPlan.getPassed() + 1); testPlan.setPassed(testPlan.getPassed() + 1);
} }
} }
@ -400,7 +392,6 @@ public class TestPlanService {
} catch (MSException e) { } catch (MSException e) {
LogUtil.error(e); LogUtil.error(e);
} }
return new ArrayList<>();
} }
public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) { public List<TestPlanDTOWithMetric> listTestPlan(QueryTestPlanRequest request) {