Class TestCase
Object
|
+--Assert
|
+--Test
|
+--TestCase
- class
TestCase
- extends Test
Defined in test_case.js
Method Summary |
TestResults
|
run(<TestResults> testResults)
Runs the test and collects the results into testResults .
|
void
|
runTest()
This is the function that actually runs the test.
|
void
|
setUp()
This function should initialize the testing environment, perhaps by
opening a new window, or just setting initial values for class members.
|
void
|
tearDown()
This function should clean up after setUp() .
|
function
|
toString()
|
<static> TestSuite
|
getSuite()
Returns a TestSuite containing tests for all
subclasses of TestCase .
|
Methods inherited from class Assert |
assertArraysEqual, assertArraysIdentical, assertDefined, assertEqual, assertFalse, assertIdentical, assertNotIdentical, assertNotNull, assertNull, assertTrue, assertUndefined, fail
|
TestCase
function TestCase(name)
run
TestResults run(<TestResults> testResults)
Runs the test and collects the results into testResults
.
This is a template method. It calls setUp
, then
runTest
, and then finally tearDown
.
Parameters:
testResults
- (Optional) - an object in which the results of the test can be collected. If testResults
is not supplied, a new instance of SimpleTestResults
will be created.
Returns:
testResults
or the newly created instance of SimpleTestResults
if testResults
was not supplied.
runTest
void runTest()
This is the function that actually runs the test. The default
implementation looks for a method with the same name as what was passed
to the constructor and calls it if such a method exists. If there is no
such method then the test fails with the message Method
"testName" not found
.
Test methods should throw an instance of
AssertionFailedError
to indicated a failed test. Note that
calling any of TestCase
's assert methods will generate an
AssertionFailedError
if the given assertion fails.
setUp
void setUp()
This function should initialize the testing environment, perhaps by
opening a new window, or just setting initial values for class members.
The default implementation does nothing.
tearDown
void tearDown()
This function should clean up after setUp()
. Any
resources that were allocated in setUp
should be destroyed
here. The default implementation does nothing. Note that this function
is called even if the test failed or caused an error.
toString
function toString()
getSuite
<static> TestSuite getSuite()
Returns a TestSuite
containing tests for all
subclasses of TestCase
.
Returns:
an all-inclusive TestSuite