From 86b19b68fc395d88995a80ab73e81bccc783ae61 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 12 Jan 2021 11:16:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=8A=A5=E5=91=8A=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/jmeter/TestResult.java | 18 ++++++++++------ .../api/service/ApiAutomationService.java | 1 + .../api/automation/report/ApiReportDetail.vue | 21 ++++++++++++------- .../report/components/ScenarioResult.vue | 2 +- .../api/definition/components/ApiVariable.vue | 2 +- .../definition/components/body/ApiBody.vue | 19 +++++++---------- .../common/json-schema/JsonSchemaEditor.vue | 4 ++-- 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java b/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java index b66d4212c0..925ff066c2 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/TestResult.java @@ -40,20 +40,26 @@ public class TestResult { this.passAssertions += count; } + private static final String separator = "<->"; + public void addScenario(ScenarioResult result) { Map> requestResultMap = new LinkedHashMap<>(); if (result != null && CollectionUtils.isNotEmpty(result.getRequestResults())) { result.getRequestResults().forEach(item -> { - if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf("<->") != -1) { - String array[] = item.getName().split("<->"); - item.setName(array[0]); - if (requestResultMap.containsKey(array[1])) { - requestResultMap.get(array[1]).add(item); + if (StringUtils.isNotEmpty(item.getName()) && item.getName().indexOf(separator) != -1) { + String array[] = item.getName().split(separator); + String scenarioName = array[array.length - 1]; + item.setName(item.getName().replace(separator + scenarioName, "")); + if (requestResultMap.containsKey(scenarioName)) { + requestResultMap.get(scenarioName).add(item); } else { List requestResults = new LinkedList<>(); requestResults.add(item); - requestResultMap.put(array[1], requestResults); + requestResultMap.put(scenarioName, requestResults); } + item.getSubRequestResults().forEach(subItem -> { + subItem.setName(item.getName()); + }); } }); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 10a92ada82..3e33bdc4d4 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -441,6 +441,7 @@ public class ApiAutomationService { ParameterConfig config = new ParameterConfig(); config.setConfig(envConfig); HashTree hashTree = request.getTestElement().generateHashTree(config); + // 调用执行方法 createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), SessionUtils.getUserId()); diff --git a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue index 9711a728ac..ed6453e2a0 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportDetail.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportDetail.vue @@ -9,14 +9,21 @@
- + + + + + + + + + + + +
- - - - - -
diff --git a/frontend/src/business/components/api/automation/report/components/ScenarioResult.vue b/frontend/src/business/components/api/automation/report/components/ScenarioResult.vue index a380bdca36..664507e874 100644 --- a/frontend/src/business/components/api/automation/report/components/ScenarioResult.vue +++ b/frontend/src/business/components/api/automation/report/components/ScenarioResult.vue @@ -1,5 +1,5 @@