Permalink
Browse files

added some use cases, fixed an issue with uninitialized array

  • Loading branch information...
tmpvar committed Feb 21, 2010
1 parent 868a98f commit 8dc7eb4f8b7ef888901723cd04b56c96ac70d1e0
Showing with 65 additions and 0 deletions.
  1. +62 −0 README.md
  2. +3 −0 lib/runner.js
View
@@ -6,6 +6,20 @@ Provides an easy way to hook into mjsunit and start running tests immediately.
Usage Example
-------------
+**myproject/test/core.js**
+
+ exports.tests = {
+ aFailingTest : function() {
+ assertTrue(false);
+ },
+ aPassingTest : function() {
+ assertFalse(false);
+ }
+ };
+
+
+**myproject/test/runner.js**
+
var suites = {
"core" : {
@@ -15,4 +29,52 @@ Usage Example
require("mjsunit.runner/lib/runner").run(suites);
+Running Tests
+-------------
+
+**All suites**
+
+ $ node myproject/test/runner.js
+
+ core 1/2 50% passing
+ ---------------------------
+ TOTALS: 1/2 50% passing
+
+**All Suites (Verbose) **
+ $ node myproject/test/runner.js --verbose
+ "Failure: expected <true> found <false> (#undefined undefined in aFailingTest)
+ Failure: expected <true> found <false>
+ at Object.assertEquals (/usr/local/lib/node/libraries/mjsunit.js:93:5)
+ at /usr/local/lib/node/libraries/mjsunit.js:113:11
+ at /path/to/myproject/test/core.js:3:5
+ at /path/to/mjsunit.runner/lib/runner.js:36:25
+ at /path/to/mjsunit.runner/lib/runner.js:50:38
+ at Object.run (/path/to/mjsunit.runner/lib/runner.js:78:9)
+ at Object.<anonymous> (/path/to/myproject/test/runner.js:7:38)
+ at [object Object].<anonymous> (node.js:978:23)
+ at [object Object].emitSuccess (node.js:241:15)
+ at [object Object].<anonymous> (node.js:678:21)
+
+ core 1/2 50% passing
+ --------------------------------------------
+ TOTALS: 1/2 50% passing
+
+**Run a test in isolation**
+
+ $ node myproject/test/runner.js --verbose --suite core --test aFailingTest
+ "Failure: expected <true> found <false> (#undefined undefined in aFailingTest)
+ Failure: expected <true> found <false>
+ at Object.assertEquals (/usr/local/lib/node/libraries/mjsunit.js:93:5)
+ at /usr/local/lib/node/libraries/mjsunit.js:113:11
+ at /path/to/myproject/test/core.js:3:5
+ at /path/to/mjsunit.runner/lib/runner.js:36:25
+ at Object.run (/path/to/mjsunit.runner/lib/runner.js:61:57)
+ at Object.<anonymous> (/path/to/myproject/test/runner.js:7:38)
+ at [object Object].<anonymous> (node.js:978:23)
+ at [object Object].emitSuccess (node.js:241:15)
+ at [object Object].<anonymous> (node.js:678:21)
+ at [object Object].emitSuccess (node.js:241:15)
+
+ 1 of 1 failed (0% success)
+
View
@@ -35,6 +35,9 @@ exports.run = function(testSuites) {
try {
suite.cases[test].call(GLOBAL);
} catch (e) {
+ if (!suite.errors) {
+ suite.errors = [];
+ }
suite.errors.push({ method: test, error: e});
errors.push({ method: test, error: e});
}

0 comments on commit 8dc7eb4

Please sign in to comment.