Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added setUp/tearDown and updated readme to reflect the change

  • Loading branch information...
commit 9e0d7d798b41dd32734bca01a53f0a76c7f513af 1 parent 8d7b4dd
@tmpvar authored
Showing with 16 additions and 1 deletion.
  1. +4 −0 README.md
  2. +12 −1 lib/runner.js
View
4 README.md
@@ -24,6 +24,10 @@ Usage Example
var suites = {
"core" : {
cases: require("./core").tests
+ /* Other options
+ setUp : function() { }, // called before every test
+ tearDown : function() { }, // called after every test
+ */
}
};
View
13 lib/runner.js
@@ -1,5 +1,8 @@
var sys = require("sys");
-process.mixin(GLOBAL, require("mjsunit"));
+
+if (!GLOBAL.assertEquals) {
+ process.mixin(GLOBAL, require("mjsunit"));
+}
exports.run = function(testSuites) {
@@ -31,6 +34,10 @@ exports.run = function(testSuites) {
var runTest = function(suiteName, suite, test) {
total++;
+
+ if (suite.setUp) {
+ suite.setUp();
+ }
try {
suite.cases[test].call(GLOBAL);
@@ -41,6 +48,10 @@ exports.run = function(testSuites) {
suite.errors.push({ suiteName:suiteName, method: test, error: e});
errors.push({ suiteName:suiteName, method: test, error: e});
}
+
+ if (suite.tearDown) {
+ suite.tearDown();
+ }
};
var runSuite = function(suiteName) {
Please sign in to comment.
Something went wrong with that request. Please try again.