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) {