TestCase.js revision 70ed32201807e3e04e8285d8718bf97239ac142d
/**
* Test case containing various tests to run.
* @param template An object containing any number of test methods, other methods,
* an optional name, and anything else the test case needs.
* @class TestCase
* @namespace Test
* @constructor
*/
/**
* Special rules for the test case. Possible subobjects
* are fail, for tests that should fail, and error, for
* tests that should throw an error.
*/
this._should = {};
//copy over all properties from the template to this object
}
//check for a valid name
if (typeof this.name != "string"){
this.name = "testCase" + (+new Date());
}
};
//restore constructor
/**
* Method to call from an async init method to
* restart the test case. When called, returns a function
* that should be called when tests are ready to continue.
* @method callback
* @return {Function} The function to call as a callback.
*/
callback: function(){
},
/**
* Resumes a paused test and runs the given function.
* @param {Function} segment (Optional) The function to run.
* If omitted, the test automatically passes.
* @return {Void}
* @method resume
*/
},
/**
* Causes the test case to wait a specified amount of time and then
* continue executing the given code.
* @param {Function} segment (Optional) The function to run after the delay.
* If omitted, the TestRunner will wait until resume() is called.
* @param {int} delay (Optional) The number of milliseconds to wait before running
* the function. If omitted, defaults to zero.
* @return {Void}
* @method wait
*/
if (typeof segment == "function"){
} else {
}, actualDelay);
}
},
//-------------------------------------------------------------------------
// Assertion Methods
//-------------------------------------------------------------------------
/**
* Asserts that a given condition is true. If not, then a YUITest.AssertionError object is thrown
* and the test fails.
* @method assert
* @param {Boolean} condition The condition to test.
* @param {String} message The message to display if the assertion fails.
*/
if (!condition){
}
},
/**
* Forces an assertion error to occur. Shortcut for YUITest.Assert.fail().
* @method fail
* @param {String} message (Optional) The message to display with the failure.
*/
},
//-------------------------------------------------------------------------
// Stub Methods
//-------------------------------------------------------------------------
/**
* Function to run once before tests start to run.
* This executes before the first call to setUp().
*/
init: function(){
//noop
},
/**
* Function to run once after tests finish running.
* This executes after the last call to tearDown().
*/
destroy: function(){
//noop
},
/**
* Function to run before each test is executed.
* @return {Void}
* @method setUp
*/
setUp : function () {
//noop
},
/**
* Function to run after each test is executed.
* @return {Void}
* @method tearDown
*/
tearDown: function () {
//noop
}
};