mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-01 03:28:59 +08:00
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
3fdeea98d3
commit
3dade654bb
@ -28,8 +28,6 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class PassRateUtil {
|
||||
|
||||
private final static String UISCENARIO_TYPE_NAME = "scenario";
|
||||
|
||||
public static String calculatePassRate(List<ApiScenarioReportResult> requestResults, ApiScenarioReport report) {
|
||||
if (CollectionUtils.isEmpty(requestResults)) {
|
||||
return "0";
|
||||
@ -70,11 +68,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 {
|
||||
@ -93,16 +95,28 @@ public class PassRateUtil {
|
||||
*
|
||||
* @param stepTrees
|
||||
* @param resultIdMap
|
||||
* @param failCount
|
||||
* @param count
|
||||
* @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 -> {
|
||||
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<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"/>
|
||||
<div v-show="showUnExecuteReport && isUi" class="metric-box">
|
||||
<div class="value">{{
|
||||
content.scenarioStepUnExecuteReport ? content.scenarioStepUnExecuteReport : 0
|
||||
uiUnExecuteCount
|
||||
}}
|
||||
</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)
|
||||
|| (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>
|
||||
|
Loading…
Reference in New Issue
Block a user