From c6b13415d8a3ca585fc729e5798b6a2a21beadc1 Mon Sep 17 00:00:00 2001 From: zhangdahai112 Date: Fri, 26 Aug 2022 14:18:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(UI=20=E8=87=AA=E5=8A=A8=E5=8C=96):=20?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=88=97=E8=A1=A8=E9=80=9A=E8=BF=87=E7=8E=87?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=BANaN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1016298 --user=张大海 【UI测试】场景列表通过率显示为NaN https://www.tapd.cn/55049933/s/1234439 --- .../api/service/ApiScenarioReportService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index 50529ef0bf..3a9a8c15c2 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -523,14 +523,18 @@ public class ApiScenarioReportService { @Nullable private boolean updateUiScenario(List requestResults, ResultDTO dto, long errorSize, String status, ApiScenarioReport report, UiScenarioWithBLOBs scenario) { - if (StringUtils.equalsAnyIgnoreCase(status, ExecuteResult.ERROR_REPORT_RESULT.toString())) { - scenario.setLastResult(status); + if (StringUtils.equalsAnyIgnoreCase(status, ExecuteResult.UN_EXECUTE.toString())) { + scenario.setLastResult(ScenarioStatus.Fail.name()); } else { - scenario.setLastResult(errorSize > 0 ? "Fail" : ScenarioStatus.Success.name()); + scenario.setLastResult(errorSize > 0 ? ScenarioStatus.Fail.name() : ScenarioStatus.Success.name()); } long successSize = requestResults.stream().filter(requestResult -> StringUtils.equalsIgnoreCase(requestResult.getStatus(), ScenarioStatus.Success.name())).count(); - scenario.setPassRate(new DecimalFormat("0%").format((float) successSize / requestResults.size())); + if (CollectionUtils.isEmpty(requestResults)) { + scenario.setPassRate("0"); + } else { + scenario.setPassRate(new DecimalFormat("0%").format((float) successSize / requestResults.size())); + } scenario.setReportId(dto.getReportId()); int executeTimes = 0; if (scenario.getExecuteTimes() != null) {