Skip to content

Instantly share code, notes, and snippets.

@sole
Created May 29, 2012 13:30
Show Gist options
  • Save sole/2828389 to your computer and use it in GitHub Desktop.
Save sole/2828389 to your computer and use it in GitHub Desktop.
munit.js advanced example
var array;
var arrayTest = new MUNIT.Test([
function lengthZeroWhenEmpty() {
this.assertEquals(0, array.length);
},
function lengthNotZeroIfNotEmpty() {
array.push(1);
this.assertTrue(array.length != 0);
},
function arrayIsRecreatedAfterEachTest() {
this.assertEquals(0, array.length);
}
]);
arrayTest.onSetup = function() {
array = [];
}
arrayTest.onTearDown = function() {
// Not that we really *need* to do anything here
// but just to show you it can be done:
array = null;
}
var results = arrayTest.runTests();
document.body.appendChild(MUNIT.prettyFormat(results));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment