Skip to content

Commit

Permalink
Mostly working Buster reporter that produces progress notifications, …
Browse files Browse the repository at this point in the history
…failure and error reports with stack traces.
  • Loading branch information
jcoglan committed Dec 7, 2012
1 parent 29b34ba commit f775bed
Showing 1 changed file with 65 additions and 7 deletions.
72 changes: 65 additions & 7 deletions source/test/reporters/buster.js
@@ -1,20 +1,78 @@
JS.Test.Reporters.extend({ JS.Test.Reporters.extend({
Buster: new JS.Class({ Buster: new JS.Class({
startRun: function(event) {},


startSuite: function(event) {}, /* Missing events:
startTest: function(event) {}, - context:unsupported
- test:setUp
- test:async
- test:tearDown
- test:timeout
- test:deferred
- uncaughtException
*/


addFault: function(event) {}, startRun: function(event) {
this._contexts = 0;
this._stack = [];
buster.emit('suite:start');
},


endTest: function(event) {}, startSuite: function(event) {
if (event.context === null) return;
this._contexts += 1;
buster.emit('context:start', {name: event.fullName});
},


endSuite: function(event) {}, startTest: function(event) {
this._testPassed = true;
buster.emit('test:start', {name: event.shortName});
},

addFault: function(event) {
if (!this._testPassed) return;
this._testPassed = false;

if (event.error.type === 'failure') {
buster.emit('test:failure', {
name: event.test.shortName,
error: {message: event.error.message}
});
}
else {
buster.emit('test:error', {
name: event.test.shortName,
error: {
message: event.error.message,
stack: event.error.backtrace
}
});
}
},

endTest: function(event) {
if (!this._testPassed) return;
buster.emit('test:success', {name: event.shortName});
},

endSuite: function(event) {
if (event.context === null) return;
buster.emit('context:end', {name: event.fullName});
},


update: function(event) {}, update: function(event) {},


endRun: function(event) {} endRun: function(event) {
buster.emit('suite:end', {
ok: event.passed,
contexts: this._contexts,
tests: event.tests,
assertions: event.assertions,
failures: event.failures,
errors: event.errors,
timeouts: 0 // <- TODO
});
}
}) })
}); });


0 comments on commit f775bed

Please sign in to comment.