From d6a2fe52ca96fe5d4f1f06824999e656b0f146e6 Mon Sep 17 00:00:00 2001 From: wenyann Date: Mon, 14 Jun 2021 16:27:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=20=E5=A4=B1=E8=B4=A5=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/dto/definition/request/MsScenario.java | 3 +++ .../api/dto/definition/request/MsThreadGroup.java | 2 +- .../dto/definition/request/ParameterConfig.java | 4 ++++ .../api/service/ApiAutomationService.java | 1 + .../api/automation/scenario/DebugRun.vue | 2 ++ .../api/automation/scenario/EditApiScenario.vue | 14 +++++++++----- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index cdf881891f..bb23ba172b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -61,6 +61,9 @@ public class MsScenario extends MsTestElement { @JSONField(ordinal = 27) private Map environmentMap; + @JSONField(ordinal = 24) + private Boolean onSampleError; + private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR; public MsScenario() { diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java index 1e922544a6..8960399233 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java @@ -66,7 +66,7 @@ public class MsThreadGroup extends MsTestElement { threadGroup.setDuration(0); threadGroup.setProperty(ThreadGroup.ON_SAMPLE_ERROR, ThreadGroup.ON_SAMPLE_ERROR_CONTINUE); threadGroup.setScheduler(false); - if (onSampleError) { + if (!onSampleError) { threadGroup.setProperty("ThreadGroup.on_sample_error", "stoptest"); } threadGroup.setSamplerController(loopController); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java index b32081c8da..7a1f1e7075 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ParameterConfig.java @@ -30,6 +30,10 @@ public class ParameterConfig { * 公共Cookie */ private boolean enableCookieShare; + /** + * 是否停止继续 + */ + private boolean onSampleError; /** * 是否是导入/导出操作 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 6bbaf19ae7..758c34c7bf 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -1079,6 +1079,7 @@ public class ApiAutomationService { scenario.setVariables(variables); } group.setEnableCookieShare(scenario.isEnableCookieShare()); + group.setOnSampleError(scenario.getOnSampleError()); LinkedList scenarios = new LinkedList<>(); scenarios.add(scenario); // 创建场景报告 diff --git a/frontend/src/business/components/api/automation/scenario/DebugRun.vue b/frontend/src/business/components/api/automation/scenario/DebugRun.vue index abef7087a2..75ea44f988 100644 --- a/frontend/src/business/components/api/automation/scenario/DebugRun.vue +++ b/frontend/src/business/components/api/automation/scenario/DebugRun.vue @@ -32,11 +32,13 @@ import {saveScenario} from "@/business/components/api/automation/api-automation" }, methods: { run() { + console.log(this.runData.onSampleError); let testPlan = createComponent('TestPlan'); let threadGroup = createComponent('ThreadGroup'); threadGroup.hashTree = []; threadGroup.name = this.reportId; threadGroup.enableCookieShare = this.runData.enableCookieShare; + threadGroup.onSampleError = this.runData.onSampleError; let map = this.environment; this.runData.projectId = getCurrentProjectID(); threadGroup.hashTree.push(this.runData); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 49d5cfee18..f74f1ed9c3 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -140,8 +140,8 @@ :isReadOnly="scenarioDefinition.length < 1" @showPopover="showPopover" :project-list="projectList" ref="envPopover"/> - - {{ $t('commons.failure_continues') }} + + {{ $t('commons.failure_continues') }} { @@ -1033,6 +1034,7 @@ export default { this.currentScenario.headers = obj.headers; } this.enableCookieShare = obj.enableCookieShare; + this.onSampleError = obj.onSampleError; if (obj.hashTree) { obj.hashTree.forEach(item => { if (!item.hashTree) { @@ -1066,7 +1068,9 @@ export default { referenced: 'Created', environmentMap: strMapToObj(this.projectEnvMap), hashTree: this.scenarioDefinition, + onSampleError: this.onSampleError, projectId: this.projectId, + }; this.currentScenario.scenarioDefinition = scenario; if (this.currentScenario.tags instanceof Array) {