The Test class is the super class of other test classes including:
Test.Unit, Test.Functional, and Test.Controller.
Typically Test is not used directly but its functions are available in inheriting classes.
Prototype Methods
fail
fail() -> undefined
Adds to the test case's failure count.
helpers
helpers() -> undefined
Returns an object of helper functions that will be used to generate a
new Assertion class for the TestCase. The base implementation returns all functions provided to tests in the constructor that do not start with test.
Functional and Controller tests overwrite this function.
init
init(name, tests, type) -> undefined
Creates a new test case. A test case is a collection of test functions and helpers.
test_some_asserts : function(){
var value = this.my_helper('hello world')
this.assert(value) //passes
},
my_helper : function(value){
return value == 'hello world'
}
}, 'unit')
{Object} - the unique name of the test. Make sure no two tests have the same name.
{Object} - An object with test functions. Functions that begin with test_ will be run as tests. Functions that don't begin with test are converted to helper functions. Do not name helper functions the same name as the test provided helpers and assertions such as assert or assertEqual as your functions will override these functions.
{Object} - The type of test ('unit', 'functional').
pass
pass() -> undefined
Adds to the test case's pass count.
run
run(callback) -> undefined
Runs all the testcase's tests and when complete calls an optional callback if provided.
{Function} - optional callback for when the test is complete