Permalink
Browse files

Mostly working Buster reporter that produces progress notifications, …

…failure and error reports with stack traces.
  • Loading branch information...
1 parent 29b34ba commit f775bedab7fb6f4d788c1f7568718596aec4c994 @jcoglan committed Dec 7, 2012
Showing with 65 additions and 7 deletions.
  1. +65 −7 source/test/reporters/buster.js
@@ -1,20 +1,78 @@
JS.Test.Reporters.extend({
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) {},
- 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.