-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reporter debug mode #12
Changes from 6 commits
93f8f8e
d324d2e
24f2dac
e80e1a8
78c3a39
e3bf8c5
4ef4537
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,15 @@ class InfluxDBReporter { | |
failed: [], | ||
skipped: [] | ||
}, | ||
list: [] | ||
list: [], | ||
debug: this.reporterOptions.debug | ||
}; | ||
const events = 'start iteration beforeItem item script request test assertion console exception done'.split(' '); | ||
events.forEach((e) => { if (typeof this[e] == 'function') newmanEmitter.on(e, (err, args) => this[e](err, args)) }); | ||
|
||
// console.log('[+] Reporter Options', reporterOptions); | ||
if (this.context.debug) { | ||
console.log('[+] Reporter Options', reporterOptions); | ||
} | ||
} | ||
|
||
start(error, args) { | ||
|
@@ -116,10 +119,15 @@ class InfluxDBReporter { | |
if(error) { | ||
this.context.currentItem.data.test_status = 'FAIL'; | ||
|
||
const failMessage = `${error.test} | ${error.name}: ${error.message}`; | ||
var failMessage = `${error.test} | ${error.name}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
if (this.context.debug) { | ||
failMessage += `: ${error.message}`; | ||
} | ||
this.context.currentItem.data.failed.push(failMessage); | ||
this.context.currentItem.data.failed_count++; | ||
this.context.assertions.failed.push(failMessage); // for debug only | ||
if (this.context.debug) { | ||
this.context.assertions.failed.push(failMessage); | ||
} | ||
} else if(args.skipped) { | ||
if(this.context.currentItem.data.test_status !== 'FAIL') { | ||
this.context.currentItem.data.test_status = 'SKIP'; | ||
|
@@ -128,31 +136,20 @@ class InfluxDBReporter { | |
const skipMessage = args.assertion; | ||
this.context.currentItem.data.skipped.push(args.assertion); | ||
this.context.currentItem.data.skipped_count++; | ||
this.context.assertions.skipped.push(skipMessage); // for debug only | ||
if (this.context.debug) { | ||
this.context.assertions.skipped.push(skipMessage); | ||
} | ||
} | ||
} | ||
|
||
item(error, args) { | ||
const binaryData = this.buildPayload(this.context.currentItem.data); | ||
// console.log('binaryData', binaryData); | ||
|
||
this.service.sendData(binaryData); | ||
} | ||
|
||
done() { | ||
this.service.disconnect(); | ||
console.log(`[+] Finished collection: ${this.options.collection.name} (${this.context.id})`); | ||
|
||
// console.log('this.context', this.context); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for removing commented stuff |
||
// console.log('this.options.collection', this.options.collection); | ||
|
||
// this.stream.write(payload); | ||
// this.stream.done(); | ||
|
||
// this.exports.push({ | ||
// name: 'newman-reporter-influxdb', | ||
// options: reporterOptions | ||
// }); | ||
} | ||
|
||
/// Private method starts here | ||
|
@@ -182,7 +179,6 @@ class InfluxDBReporter { | |
.replace(/,/g, '\\,') | ||
.replace(/=/g, '\\='); | ||
} | ||
|
||
}; | ||
|
||
module.exports = InfluxDBReporter; | ||
module.exports = InfluxDBReporter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this to start() method, as other --reporter-{...} declaration are specified there..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can have statement like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed, but I would leave it like that because I'm already using
debug
in the constructor's if-statement.https://github.com/tomaszsluszniak/newman-reporter-influxdb/blob/4ef4537f594c2677fba813bf8a993f3e35e5b738/src/influxdb-reporter.js#L30