Created
January 27, 2011 20:07
-
-
Save repeatingbeats/799136 to your computer and use it in GitHub Desktop.
Example structure for nodeunit tests with nested groups and setUp/tearDown functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example structure for nodeunit tests with nested groups and setup/teardown | |
* functions. Run | nodeunit nodeunit_example.js | to see a printout of | |
* function names in the order that they are called. There aren't any actual | |
* tests here. | |
*/ | |
process.env.NODE_ENV = 'test'; | |
var testCase = require('nodeunit').testCase; | |
exports.groupOne = testCase({ | |
setUp: function groupOneSetup(cb) { | |
console.log(arguments.callee.name); | |
cb(); | |
}, | |
tearDown: function groupOneTearDown(cb) { | |
console.log(arguments.callee.name); | |
cb(); | |
}, | |
groupOneTestOne: function groupOneTestOne(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
}, | |
groupOneTestTwo: function groupOneTestTwo(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
}, | |
nestedGroup: testCase({ | |
setUp: function groupOneNestedSetup(cb) { | |
console.log(arguments.callee.name); | |
cb(); | |
}, | |
tearDown: function groupOneNestedTearDown(cb) { | |
console.log(arguments.callee.name); | |
cb(); | |
}, | |
groupOneNestedTestOne: function groupOneNestedTestOne(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
}, | |
groupOneNestedTestTwo: function groupOneNestedTestTwo(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
}, | |
}), | |
groupOneTestThree: function groupOneTestThree(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
} | |
}); | |
exports.groupTwo = { | |
groupTwoTestOne: function groupTwoTestOne(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
}, | |
groupTwoTestTwo: function groupTwoTestTwo(test) { | |
console.log(arguments.callee.name); | |
test.done(); | |
} | |
} |
wow! works like a charm :) keep it up
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is updated https://github.com/caolan/nodeunit#groups-setup-and-teardown