Permalink
Browse files

Better tests for testcase.error and its dump to firebug

  • Loading branch information...
1 parent b3d2316 commit 1e2ea7ce2c3506de601f6eb0734839be030c8526 @choan choan committed Nov 29, 2008
Showing with 25 additions and 4 deletions.
  1. +3 −3 src/test_case.js
  2. +22 −1 test/unit/test_case_test.html
View
@@ -87,10 +87,10 @@ JsUnitTest.Unit.Testcase.prototype.error = function(error, test) {
this.errors++;
this.actions['retry with throw'] = function() { test.run(true); };
this.messages.push(error.name + ": "+ error.message + "(" + JsUnitTest.inspect(error) + ")");
- if( typeof console != "undefined" && console.error && console.warn && console.info) {
+ if( typeof console != "undefined" && console.error) {
console.error("Test '" + test.name + "' died, exception and test follows");
- console.info(error);
- console.warn(test.test.toString());
+ console.error(error);
+ console.error(test.test.toString());
}
};
@@ -83,12 +83,33 @@
// Error
testError: function() { with(this) {
- testcase.error({name: "name", message: "An Error"}, this);
+ testcase.error({name: "name", message: "An Error"}, testcase);
assertEqual(0, testcase.assertions, "Assertions");
assertEqual(1, testcase.errors, "Errors");
assertEqual("name: An Error([object Object])", testcase.messages[0], 'Should be equal');
assertEqual('error', testcase.status(), 'Should be equal');
}},
+
+ testErrorOnFirebug : function() { with(this) {
+ var results = [];
+ var orig_console = window.console;
+ try {
+ // we need to delete the firebug console on Firefox
+ // but the delete statement fails on IE
+ delete window.console;
+ } catch(e) {};
+ window.console = {
+ error: function(s) {
+ results.push(s);
+ }
+ };
+ testcase.error({name: "name", message: "An Error"}, testcase);
+ var fn = function() {};
+ assertEqual("Test 'name' died, exception and test follows", results[0]);
+ assertEqual(fn.toString(), results[2]);
+ assertHashEqual({ message: 'An Error', name: 'name' }, results[1]);
+ window.console = orig_console;
+ }}
});
// ]]>

0 comments on commit 1e2ea7c

Please sign in to comment.