From b377d398ab5fd9f5a7b210560c609744ad01daf3 Mon Sep 17 00:00:00 2001 From: q4speed Date: Tue, 19 May 2020 18:10:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=BA=E6=99=AF=E5=90=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BAnull=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/test/model/ScenarioModel.js | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/frontend/src/business/components/api/test/model/ScenarioModel.js b/frontend/src/business/components/api/test/model/ScenarioModel.js index e0abd9d2e9..bbb129aa5a 100644 --- a/frontend/src/business/components/api/test/model/ScenarioModel.js +++ b/frontend/src/business/components/api/test/model/ScenarioModel.js @@ -96,8 +96,8 @@ export class Test extends BaseConfig { super(); this.version = '1.0.0'; this.id = uuid(); - this.name = null; - this.projectId = null; + this.name = undefined; + this.projectId = undefined; this.scenarioDefinition = []; this.set(options); @@ -122,8 +122,8 @@ export class Scenario extends BaseConfig { constructor(options) { super(); this.id = uuid(); - this.name = null; - this.url = null; + this.name = undefined; + this.url = undefined; this.variables = []; this.headers = []; this.requests = []; @@ -143,14 +143,14 @@ export class Request extends BaseConfig { constructor(options) { super(); this.id = uuid(); - this.name = null; - this.url = null; - this.method = null; + this.name = undefined; + this.url = undefined; + this.method = undefined; this.parameters = []; this.headers = []; - this.body = null; - this.assertions = null; - this.extract = null; + this.body = undefined; + this.assertions = undefined; + this.extract = undefined; this.set(options); this.sets({parameters: KeyValue, headers: KeyValue}, options); @@ -173,8 +173,8 @@ export class Request extends BaseConfig { export class Body extends BaseConfig { constructor(options) { super(); - this.type = null; - this.raw = null; + this.type = undefined; + this.raw = undefined; this.kvs = []; this.set(options); @@ -225,7 +225,7 @@ export class Assertions extends BaseConfig { super(); this.text = []; this.regex = []; - this.duration = null; + this.duration = undefined; this.set(options); this.sets({text: Text, regex: Regex}, options); @@ -248,9 +248,9 @@ export class AssertionType extends BaseConfig { export class Text extends AssertionType { constructor(options) { super(ASSERTION_TYPE.TEXT); - this.subject = null; - this.condition = null; - this.value = null; + this.subject = undefined; + this.condition = undefined; + this.value = undefined; this.set(options); } @@ -259,9 +259,9 @@ export class Text extends AssertionType { export class Regex extends AssertionType { constructor(options) { super(ASSERTION_TYPE.REGEX); - this.subject = null; - this.expression = null; - this.description = null; + this.subject = undefined; + this.expression = undefined; + this.description = undefined; this.set(options); } @@ -274,7 +274,7 @@ export class Regex extends AssertionType { export class ResponseTime extends AssertionType { constructor(options) { super(ASSERTION_TYPE.RESPONSE_TIME); - this.value = null; + this.value = undefined; this.set(options); } @@ -311,10 +311,10 @@ export class ExtractType extends BaseConfig { export class ExtractCommon extends ExtractType { constructor(type, options) { super(type); - this.variable = null; + this.variable = undefined; this.value = ""; // ${variable} - this.expression = null; - this.description = null; + this.expression = undefined; + this.description = undefined; this.set(options); } @@ -386,7 +386,7 @@ class JMeterTestPlan extends Element { class JMXGenerator { constructor(test) { - if (!test || !(test instanceof Test)) return null; + if (!test || !(test instanceof Test)) return undefined; if (!test.id) { test.id = "#NULL_TEST_ID#"; @@ -395,7 +395,8 @@ class JMXGenerator { let testPlan = new TestPlan(test.name); test.scenarioDefinition.forEach(scenario => { - let threadGroup = new ThreadGroup(scenario.name + SPLIT + scenario.id); + let testName = scenario.name ? scenario.name + SPLIT + scenario.id : SPLIT + scenario.id; + let threadGroup = new ThreadGroup(testName); this.addScenarioVariables(threadGroup, scenario); @@ -405,7 +406,7 @@ class JMXGenerator { if (!request.isValid()) return; // test.id用于处理结果时区分属于哪个测试 - let name = request.name + SPLIT + test.id; + let name = request.name ? request.name + SPLIT + test.id : SPLIT + test.id; let httpSamplerProxy = new HTTPSamplerProxy(name, new JMXRequest(request)); this.addRequestHeader(httpSamplerProxy, request);