This commit is contained in:
chenjianxing 2020-05-19 18:20:57 +08:00
commit ef4f372c08
1 changed files with 27 additions and 26 deletions

View File

@ -96,8 +96,8 @@ export class Test extends BaseConfig {
super(); super();
this.version = '1.0.0'; this.version = '1.0.0';
this.id = uuid(); this.id = uuid();
this.name = null; this.name = undefined;
this.projectId = null; this.projectId = undefined;
this.scenarioDefinition = []; this.scenarioDefinition = [];
this.set(options); this.set(options);
@ -122,8 +122,8 @@ export class Scenario extends BaseConfig {
constructor(options) { constructor(options) {
super(); super();
this.id = uuid(); this.id = uuid();
this.name = null; this.name = undefined;
this.url = null; this.url = undefined;
this.variables = []; this.variables = [];
this.headers = []; this.headers = [];
this.requests = []; this.requests = [];
@ -143,14 +143,14 @@ export class Request extends BaseConfig {
constructor(options) { constructor(options) {
super(); super();
this.id = uuid(); this.id = uuid();
this.name = null; this.name = undefined;
this.url = null; this.url = undefined;
this.method = null; this.method = undefined;
this.parameters = []; this.parameters = [];
this.headers = []; this.headers = [];
this.body = null; this.body = undefined;
this.assertions = null; this.assertions = undefined;
this.extract = null; this.extract = undefined;
this.set(options); this.set(options);
this.sets({parameters: KeyValue, headers: KeyValue}, options); this.sets({parameters: KeyValue, headers: KeyValue}, options);
@ -173,8 +173,8 @@ export class Request extends BaseConfig {
export class Body extends BaseConfig { export class Body extends BaseConfig {
constructor(options) { constructor(options) {
super(); super();
this.type = null; this.type = undefined;
this.raw = null; this.raw = undefined;
this.kvs = []; this.kvs = [];
this.set(options); this.set(options);
@ -225,7 +225,7 @@ export class Assertions extends BaseConfig {
super(); super();
this.text = []; this.text = [];
this.regex = []; this.regex = [];
this.duration = null; this.duration = undefined;
this.set(options); this.set(options);
this.sets({text: Text, regex: Regex}, options); this.sets({text: Text, regex: Regex}, options);
@ -248,9 +248,9 @@ export class AssertionType extends BaseConfig {
export class Text extends AssertionType { export class Text extends AssertionType {
constructor(options) { constructor(options) {
super(ASSERTION_TYPE.TEXT); super(ASSERTION_TYPE.TEXT);
this.subject = null; this.subject = undefined;
this.condition = null; this.condition = undefined;
this.value = null; this.value = undefined;
this.set(options); this.set(options);
} }
@ -259,9 +259,9 @@ export class Text extends AssertionType {
export class Regex extends AssertionType { export class Regex extends AssertionType {
constructor(options) { constructor(options) {
super(ASSERTION_TYPE.REGEX); super(ASSERTION_TYPE.REGEX);
this.subject = null; this.subject = undefined;
this.expression = null; this.expression = undefined;
this.description = null; this.description = undefined;
this.set(options); this.set(options);
} }
@ -274,7 +274,7 @@ export class Regex extends AssertionType {
export class ResponseTime extends AssertionType { export class ResponseTime extends AssertionType {
constructor(options) { constructor(options) {
super(ASSERTION_TYPE.RESPONSE_TIME); super(ASSERTION_TYPE.RESPONSE_TIME);
this.value = null; this.value = undefined;
this.set(options); this.set(options);
} }
@ -311,10 +311,10 @@ export class ExtractType extends BaseConfig {
export class ExtractCommon extends ExtractType { export class ExtractCommon extends ExtractType {
constructor(type, options) { constructor(type, options) {
super(type); super(type);
this.variable = null; this.variable = undefined;
this.value = ""; // ${variable} this.value = ""; // ${variable}
this.expression = null; this.expression = undefined;
this.description = null; this.description = undefined;
this.set(options); this.set(options);
} }
@ -386,7 +386,7 @@ class JMeterTestPlan extends Element {
class JMXGenerator { class JMXGenerator {
constructor(test) { constructor(test) {
if (!test || !(test instanceof Test)) return null; if (!test || !(test instanceof Test)) return undefined;
if (!test.id) { if (!test.id) {
test.id = "#NULL_TEST_ID#"; test.id = "#NULL_TEST_ID#";
@ -395,7 +395,8 @@ class JMXGenerator {
let testPlan = new TestPlan(test.name); let testPlan = new TestPlan(test.name);
test.scenarioDefinition.forEach(scenario => { 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); this.addScenarioVariables(threadGroup, scenario);
@ -405,7 +406,7 @@ class JMXGenerator {
if (!request.isValid()) return; if (!request.isValid()) return;
// test.id用于处理结果时区分属于哪个测试 // 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)); let httpSamplerProxy = new HTTPSamplerProxy(name, new JMXRequest(request));
this.addRequestHeader(httpSamplerProxy, request); this.addRequestHeader(httpSamplerProxy, request);