Test.Runner Class
Runs test suites and test cases, providing events to allowing for the interpretation of test results.
Item Index
Methods
- _addTestCaseToTestTree static
- _addTestSuiteToTestTree static
- _buildTestTree static
- _execNonTestMethod
- _handleError static
- _handleTestObjectComplete
- _next static
- _run static
- _runTest static
- add static
- callback
- clear static
- getCoverage
- getName
- getResults
- isRunning
- isWaiting static
- resume static
- run static
- setName
Properties
- _cur static
- _data static
- _groups static
- _ignoreEmpty static
- _lastResults static
- _log static
- _root static
- _running static
- _waiting static
- masterSuite static
Events
- begin static
- complete static
- error static
- fail static
- ignore static
- pass static
- testcasebegin static
- testcasecomplete static
- testsuitebegin static
- testsuitecomplete static
Methods
_addTestCaseToTestTree
-
parentNode
-
testCase
Adds a test case to the test tree as a child of the specified node.
Parameters:
-
parentNode
TestNodeThe node to add the test case to as a child.
-
testCase
Test.TestCaseThe test case to add.
Returns:
_addTestSuiteToTestTree
-
parentNode
-
testSuite
Adds a test suite to the test tree as a child of the specified node.
Parameters:
-
parentNode
TestNodeThe node to add the test suite to as a child.
-
testSuite
Test.TestSuiteThe test suite to add.
Returns:
_buildTestTree
()
Void
private
static
Builds the test tree based on items in the master suite. The tree is a hierarchical representation of the test suites, test cases, and test functions. The resulting tree is stored in _root and the pointer _cur is set to the root initially.
Returns:
_execNonTestMethod
-
node
-
methodName
-
allowAsync
Executes a non-test method (init, setUp, tearDown, destroy) and traps an errors. If an error occurs, an error event is fired.
Parameters:
Returns:
_handleError
-
error
Handles an error as if it occurred within the currently executing test. This is for mock methods that may be called asynchronously and therefore out of the scope of the TestRunner. Previously, this error would bubble up to the browser. Now, this method is used to tell TestRunner about the error. This should never be called by anyplace other than the Mock object.
Parameters:
-
error
ErrorThe error object.
Returns:
_handleTestObjectComplete
-
node
Handles the completion of a test object's tests. Tallies test results from one level up to the next.
Parameters:
-
node
TestNodeThe TestNode representing the test object.
Returns:
_next
()
TestNode
private
static
Retrieves the next node in the test tree.
Returns:
_run
-
testObject
Runs a test case or test suite, returning the results.
Parameters:
-
testObject
Test.TestCase | YUITest.TestSuiteThe test case or test suite to run.
Returns:
_runTest
-
node
Runs a single test based on the data provided in the node.
Parameters:
-
node
TestNodeThe TestNode representing the test to run.
Returns:
add
-
testObject
Adds a test suite or test case to the list of test objects to run.
Parameters:
-
testObject
ObjectEither a TestCase or a TestSuite that should be run.
Returns:
callback
()
Function
private
Used to continue processing when a method marked with "async:" is executed. This should not be used in test methods, only in init(). Each argument is a string, and when the returned function is executed, the arguments are assigned to the context data object using the string as the key name (value is the argument itself).
Returns:
clear
()
Void
static
Removes all test objects from the runner.
Returns:
getCoverage
-
format
Returns the coverage report for the files that have been executed. This returns only coverage information for files that have been instrumented using YUI Test Coverage and only those that were run in the same pass.
Parameters:
-
format
Function(Optional) A coverage format to return results in.
getName
()
String
Retrieves the name of the current result set.
Returns:
getResults
-
format
Returns the last complete results set from the TestRunner. Null is returned if the TestRunner is running or no tests have been run.
Parameters:
-
format
Function(Optional) A test format to return the results in.
isRunning
()
Boolean
Indicates that the TestRunner is busy running tests and therefore can't be stopped and results cannot be gathered.
Returns:
isWaiting
()
Boolean
static
Indicates if the TestRunner is waiting for a test to resume
Returns:
resume
-
segment
Resumes the TestRunner after wait() was called.
Parameters:
-
segment
FunctionThe function to run as the rest of the haulted test.
Returns:
run
-
options
Runs the test suite.
Parameters:
Returns:
setName
-
name
The name assigned to the master suite of the TestRunner. This is the name that is output as the root's name when results are retrieved.
Parameters:
-
name
StringThe name of the result set.
Returns:
Properties
_cur
TestNode
private
static
Pointer to the current node in the test tree.
_groups
String
private
static
The list of test groups to run. The list is represented by a comma delimited string with commas at the start and end.
_ignoreEmpty
Boolean
private
static
If true, YUITest will not fire an error for tests with no Asserts.
_lastResults
Object
private
static
Holds copy of the results object generated when all tests are complete.
_root
TestNode
private
static
Pointer to the root node in the test tree.
_waiting
Boolean
private
static
Indicates if the TestRunner is waiting as a result of wait() being called.
masterSuite
YUITest.TestSuite
private
static
Suite on which to attach all TestSuites and TestCases to be run.
Events
begin
static
Fires when the run() method is called.
complete
static
Fires when all test suites and test cases have been completed.
error
static
Fires when a non-test method has an error.
fail
static
Fires when a test has failed.
ignore
static
Fires when a test has been ignored.
pass
static
Fires when a test has passed.
testcasebegin
static
Fires when a test case is opened but before the first test is executed.
testcasecomplete
static
Fires when all tests in a test case have been executed.
testsuitebegin
static
Fires when a test suite is opened but before the first test is executed.
testsuitecomplete
static
Fires when all test cases in a test suite have been completed.