Test

MVC.Test, fail, helpers, run, run_helper, run_test, toElement

Related

Test.Assertions, Test.Unit, Test.Functional, Test.Controller

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.

Constructor

MVC.Test

new MVC.Test(name, tests, type) -> Test

Creates a new test case. A test case is a collection of test functions and helpers.

new MVC.Test('TestCaseName',{
  test_some_asserts : function(){
    var value = this.my_helper('hello world')
    this.assert(value)      //passes
  },
  my_helper : function(value){
    return value == 'hello world'
  }
}, 'unit')
- The unique name of the test. Make sure no two tests have the same name.
- 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.
- The type of test ('unit', 'functional').

Prototype Methods

fail

fail()

Adds to the test case's failure count.

helpers

helpers()

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.

run

run(callback)

Runs all the testcase's tests and when complete calls an optional callback if provided.

run_helper

run_helper(helper_name)

Runs a helper function.

run_test

run_test(test_name)

Runs the test specified by the given test_name.

toElement

toElement()

Returns an HTMLElement that is the graphical representation of this test.