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