diff --git a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java index 5a1c116762..1cb6d5e44b 100644 --- a/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/scenario/ApiScenarioExecuteService.java @@ -34,6 +34,7 @@ import io.metersphere.dto.JmeterRunRequestDTO; import io.metersphere.dto.MsExecResponseDTO; import io.metersphere.dto.RunModeConfigDTO; import io.metersphere.i18n.Translator; +import io.metersphere.plugin.core.MsTestElement; import io.metersphere.service.EnvironmentGroupProjectService; import io.metersphere.track.service.TestPlanScenarioCaseService; import io.metersphere.utils.LoggerUtil; @@ -376,13 +377,23 @@ public class ApiScenarioExecuteService { } catch (Exception e) { MSException.throwException(e.getMessage()); } - APIScenarioReportResult report = apiScenarioReportService.init(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), SessionUtils.getUserId(), request.getConfig(), request.getId()); apiScenarioReportMapper.insert(report); if (request.isSaved()) { ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(request.getScenarioId()); apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig() != null ? request.getConfig().getReportType() : null); + } else { + if (request.getTestElement() != null && CollectionUtils.isNotEmpty(request.getTestElement().getHashTree())) { + ApiScenarioWithBLOBs scenario = new ApiScenarioWithBLOBs(); + scenario.setId(request.getScenarioId()); + MsTestElement testElement = request.getTestElement().getHashTree().get(0).getHashTree().get(0); + if (testElement != null) { + scenario.setName(testElement.getName()); + scenario.setScenarioDefinition(JSON.toJSONString(testElement)); + apiScenarioReportStructureService.save(scenario, report.getId(), request.getConfig() != null ? request.getConfig().getReportType() : null); + } + } } uploadBodyFiles(request.getBodyFileRequestIds(), bodyFiles); FileUtils.createBodyFiles(request.getScenarioFileIds(), scenarioFiles);