fix(UI 自动化) ui测试报告计数错误修复
--bug=1016623 --user=张大海 【UI测试】当成功的步骤为0时-通过率计算错误 https://www.tapd.cn/55049933/s/1240131 --bug=1016626 --user=张大海 【UI测试】生成报告-步骤统计-未执行统计错误 https://www.tapd.cn/55049933/s/1240133
This commit is contained in:
parent
e03f997b17
commit
6e1a437741
|
@ -28,8 +28,6 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public class PassRateUtil {
|
public class PassRateUtil {
|
||||||
|
|
||||||
private final static String UISCENARIO_TYPE_NAME = "scenario";
|
|
||||||
|
|
||||||
public static String calculatePassRate(List<ApiScenarioReportResult> requestResults, ApiScenarioReport report) {
|
public static String calculatePassRate(List<ApiScenarioReportResult> requestResults, ApiScenarioReport report) {
|
||||||
if (CollectionUtils.isEmpty(requestResults)) {
|
if (CollectionUtils.isEmpty(requestResults)) {
|
||||||
return "0";
|
return "0";
|
||||||
|
@ -70,11 +68,15 @@ public class PassRateUtil {
|
||||||
AtomicLong atomicLong = new AtomicLong();
|
AtomicLong atomicLong = new AtomicLong();
|
||||||
stepList.forEach(stepFather -> {
|
stepList.forEach(stepFather -> {
|
||||||
stepFather.getChildren().forEach(step -> {
|
stepFather.getChildren().forEach(step -> {
|
||||||
if (StringUtils.equalsIgnoreCase(step.getType(), UISCENARIO_TYPE_NAME)) {
|
//scenario 拥有 hashtree 的控制语句
|
||||||
|
if (CollectionUtils.isNotEmpty(step.getChildren())) {
|
||||||
AtomicLong failCount = new AtomicLong();
|
AtomicLong failCount = new AtomicLong();
|
||||||
|
AtomicLong unExecuteCount = new AtomicLong();
|
||||||
getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), failCount);
|
getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), failCount);
|
||||||
|
getUIUnExecuteStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), unExecuteCount);
|
||||||
|
|
||||||
//复制或者嵌套场景的成功只算 1 次
|
//复制或者嵌套场景的成功只算 1 次
|
||||||
if (failCount.get() == 0) {
|
if (failCount.get() == 0 && unExecuteCount.get() == 0) {
|
||||||
atomicLong.getAndAdd(1);
|
atomicLong.getAndAdd(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,16 +95,28 @@ public class PassRateUtil {
|
||||||
*
|
*
|
||||||
* @param stepTrees
|
* @param stepTrees
|
||||||
* @param resultIdMap
|
* @param resultIdMap
|
||||||
* @param failCount
|
* @param count
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static void getUIFailStepCount(Map<String, List<ApiScenarioReportResult>> resultIdMap, List<StepTreeDTO> stepTrees, AtomicLong failCount) {
|
private static void getUIFailStepCount(Map<String, List<ApiScenarioReportResult>> resultIdMap, List<StepTreeDTO> stepTrees, AtomicLong count) {
|
||||||
stepTrees.forEach(step -> {
|
stepTrees.forEach(step -> {
|
||||||
if (StringUtils.equalsIgnoreCase(step.getType(), UISCENARIO_TYPE_NAME)) {
|
if (CollectionUtils.isNotEmpty(step.getChildren())) {
|
||||||
getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), failCount);
|
getUIFailStepCount(resultIdMap, Optional.ofNullable(step.getChildren()).orElse(new ArrayList<>()), count);
|
||||||
} else {
|
} else {
|
||||||
if (resultIdMap.containsKey(step.getResourceId()) && CollectionUtils.isNotEmpty(resultIdMap.get(step.getResourceId()))) {
|
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<String, List<ApiScenarioReportResult>> resultIdMap, List<StepTreeDTO> 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
<span v-show="showUnExecuteReport && isUi" class="ms-point-unexecute"/>
|
<span v-show="showUnExecuteReport && isUi" class="ms-point-unexecute"/>
|
||||||
<div v-show="showUnExecuteReport && isUi" class="metric-box">
|
<div v-show="showUnExecuteReport && isUi" class="metric-box">
|
||||||
<div class="value">{{
|
<div class="value">{{
|
||||||
content.scenarioStepUnExecuteReport ? content.scenarioStepUnExecuteReport : 0
|
uiUnExecuteCount
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div class="name">{{ $t('api_test.home_page.detail_card.unexecute') }}</div>
|
<div class="name">{{ $t('api_test.home_page.detail_card.unexecute') }}</div>
|
||||||
|
@ -310,6 +310,13 @@ export default {
|
||||||
return (this.content.scenarioStepUnExecuteReport && this.content.scenarioStepUnExecuteReport > 0)
|
return (this.content.scenarioStepUnExecuteReport && this.content.scenarioStepUnExecuteReport > 0)
|
||||||
|| (this.content.scenarioUnExecute && this.content.scenarioUnExecute > 0) || (this.content.unExecute && this.content.unExecute > 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue