Permalink
Browse files

correctly generate and report warnings

  • Loading branch information...
1 parent 1f3da24 commit 307198c1497c684792e7b71fbc0fbedf66cae26c @dchelimsky dchelimsky committed Sep 19, 2008
Showing with 16 additions and 3 deletions.
  1. +3 −2 src/runner.js
  2. +3 −1 test/unit/runner_test.html
  3. +10 −0 test/unit/test_case_test.html
View
@@ -55,15 +55,16 @@ JsUnitTest.Unit.Runner.prototype.getResult = function() {
tests: this.tests.length,
assertions: 0,
failures: 0,
- errors: 0
+ errors: 0,
+ warnings: 0
};
for (var i=0; i < this.tests.length; i++) {
var test = this.tests[i];
results.assertions += test.assertions;
results.failures += test.failures;
results.errors += test.errors;
- warnings.errors += test.warnings;
+ results.warnings += test.warnings;
};
return results;
};
@@ -42,6 +42,7 @@
JsUnitTest.Unit.Testcase.prototype.assertions = 1;
JsUnitTest.Unit.Testcase.prototype.failures = 0;
JsUnitTest.Unit.Testcase.prototype.errors = 0;
+ JsUnitTest.Unit.Testcase.prototype.warnings = 0;
JsUnitTest.Unit.Logger = function() {};
JsUnitTest.Unit.Logger.prototype.start = function() {};
JsUnitTest.Unit.Logger.prototype.finish = function() {};
@@ -64,7 +65,8 @@
assertEqual(2, results.assertions);
assertEqual(0, results.errors);
assertEqual(0, results.failures);
- assertEqual("2 tests, 2 assertions, 0 failures, 0 errors", runner.summary());
+ assertEqual(0, results.warnings);
+ assertEqual("2 tests, 2 assertions, 0 failures, 0 errors, 0 warnings", runner.summary());
}},
@@ -71,6 +71,16 @@
assertEqual('failed', testcase.status(), 'Should be equal');
}},
+ // Warn
+ testWarn: function() { with(this) {
+ testcase.warn("xxx");
+ assertEqual(0, testcase.assertions, "Assertions");
+ assertEqual(0, testcase.failures, "Failures");
+ assertEqual(1, testcase.warnings, "Warnings");
+ assertMatch(/^Warning: xxx/, testcase.messages[0]);
+ assertEqual('warning', testcase.status(), 'Should be equal');
+ }},
+
// Error
testError: function() { with(this) {
testcase.error({name: "name", message: "An Error"});

0 comments on commit 307198c

Please sign in to comment.