diff --git a/backend/src/main/java/io/metersphere/api/service/utils/PassRateUtil.java b/backend/src/main/java/io/metersphere/api/service/utils/PassRateUtil.java index efd2425d64..6146506f51 100644 --- a/backend/src/main/java/io/metersphere/api/service/utils/PassRateUtil.java +++ b/backend/src/main/java/io/metersphere/api/service/utils/PassRateUtil.java @@ -69,11 +69,15 @@ public class PassRateUtil { AtomicLong atomicLong = new AtomicLong(); stepList.forEach(stepFather -> { stepFather.getChildren().forEach(step -> { - if (StringUtils.equalsIgnoreCase(step.getType(), UISCENARIO_TYPE_NAME)) { + //scenario 拥有 hashtree 的控制语句 + if (CollectionUtils.isNotEmpty(step.getChildren())) { AtomicLong failCount = new AtomicLong(); + AtomicLong unExecuteCount = new AtomicLong(); getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), failCount); + getUIUnExecuteStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), unExecuteCount); + //复制或者嵌套场景的成功只算 1 次 - if (failCount.get() == 0) { + if (failCount.get() == 0 && unExecuteCount.get() == 0) { atomicLong.getAndAdd(1); } } else { @@ -92,16 +96,28 @@ public class PassRateUtil { * * @param stepTrees * @param resultIdMap - * @param failCount + * @param count * @return */ - private static void getUIFailStepCount(Map> resultIdMap, List stepTrees, AtomicLong failCount) { + private static void getUIFailStepCount(Map> resultIdMap, List stepTrees, AtomicLong count) { stepTrees.forEach(step -> { - if (StringUtils.equalsIgnoreCase(step.getType(), UISCENARIO_TYPE_NAME)) { - getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), failCount); + if (CollectionUtils.isNotEmpty(step.getChildren())) { + getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), count); } else { if (resultIdMap.containsKey(step.getResourceId()) && CollectionUtils.isNotEmpty(resultIdMap.get(step.getResourceId()))) { - calculateCount(resultIdMap, failCount, step, ScenarioStatus.Fail.name()); + calculateCount(resultIdMap, count, step, ScenarioStatus.Fail.name()); + } + } + }); + } + + private static void getUIUnExecuteStepCount(Map> resultIdMap, List stepTrees, AtomicLong count) { + stepTrees.forEach(step -> { + if (CollectionUtils.isNotEmpty(step.getChildren())) { + getUIUnExecuteStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), count); + } else { + if (!resultIdMap.containsKey(step.getResourceId())) { + count.getAndIncrement(); } } }); diff --git a/frontend/src/business/components/api/automation/report/components/MetricChart.vue b/frontend/src/business/components/api/automation/report/components/MetricChart.vue index 1ca36452ad..cda1a7b9dc 100644 --- a/frontend/src/business/components/api/automation/report/components/MetricChart.vue +++ b/frontend/src/business/components/api/automation/report/components/MetricChart.vue @@ -129,7 +129,7 @@
{{ - content.unExecute ? content.unExecute : 0 + uiUnExecuteCount }}
{{ $t('api_test.home_page.detail_card.unexecute') }}
@@ -220,7 +220,7 @@ export default { } else { this.time = this.totalTime + "ms" } - }, + } }, computed: { totalCount() { @@ -310,6 +310,13 @@ export default { return (this.content.scenarioStepUnExecuteReport && this.content.scenarioStepUnExecuteReport > 0) || (this.content.scenarioUnExecute && this.content.scenarioUnExecute > 0) || (this.content.unExecute && this.content.unExecute > 0); }, + uiUnExecuteCount() { + if (this.content.scenarioStepTotal) { + return this.content.scenarioStepTotal - (this.content.scenarioStepSuccess || 0) - (this.content.scenarioStepError || 0); + } else { + return 0; + } + } }, }