static
Class YAHOO.tool.TestRunner
Runs test suites and test cases, providing events to allowing for the
interpretation of test results.
Properties
_cur
- private static TestNode
Pointer to the current node in the test tree.
Holds copy of the results object generated when all tests are
complete.
_root
- private static TestNode
Pointer to the root node in the test tree.
_running
- private static Boolean
Indicates if the TestRunner is currently running tests.
masterSuite
- private static YAHOO.tool.TestSuite
Suite on which to attach all TestSuites and TestCases to be run.
Methods
private
static
Void
_addTestCaseToTestTree
(
parentNode
,
testCase
)
Adds a test case to the test tree as a child of the specified node.
- Parameters:
-
parentNode
<TestNode>
The node to add the test case to as a child.
-
testCase
<YAHOO.tool.TestCase>
The test case to add.
private
static
Void
_addTestSuiteToTestTree
(
parentNode
,
testSuite
)
Adds a test suite to the test tree as a child of the specified node.
- Parameters:
-
parentNode
<TestNode>
The node to add the test suite to as a child.
-
testSuite
<YAHOO.tool.TestSuite>
The test suite to add.
private
static
Void
_buildTestTree
(
)
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.
private
static
Void
_handleTestObjectComplete
(
node
)
Handles the completion of a test object's tests. Tallies test results
from one level up to the next.
- Parameters:
-
node
<TestNode>
The TestNode representing the test object.
private
static
TestNode
_next
(
)
Retrieves the next node in the test tree.
- Returns:
TestNode
- The next node in the test tree or null if the end is reached.
private
static
Object
_run
(
testObject
)
Runs a test case or test suite, returning the results.
- Parameters:
-
testObject
<YAHOO.tool.TestCase|YAHOO.tool.TestSuite>
The test case or test suite to run.
- Returns:
Object
- Results of the execution with properties passed, failed, and total.
private
static
Void
_runTest
(
node
)
Runs a single test based on the data provided in the node.
- Parameters:
-
node
<TestNode>
The TestNode representing the test to run.
static
Void
add
(
testObject
)
Adds a test suite or test case to the list of test objects to run.
- Parameters:
-
testObject
<object>
Either a TestCase or a TestSuite that should be run.
static
Void
clear
(
)
Removes all test objects from the runner.
protected
static
void
fireEvent
(
type
,
data
)
Fires events for the TestRunner. This overrides the default fireEvent()
method from EventProvider to add the type property to the data that is
passed through on each event call.
- Parameters:
-
type
<String>
The type of event to fire.
-
data
<Object>
(Optional) Data for the event.
Object|String
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.
- Returns:
Object|String
- Either the coverage object or, if a coverage
format is specified, a string representing the results in that format.
String
getName
(
)
Retrieves the name of the current result set.
- Returns:
String
- The name of the result set.
Object|String
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.
- Returns:
Object|String
- Either the results object or, if a test format is
passed as the argument, a string representing the results in a specific
format.
Boolean
isRunning
(
)
Indicates that the TestRunner is busy running tests and therefore can't
be stopped and results cannot be gathered.
- Returns:
Boolean
- True if the TestRunner is running, false if not.
static
Void
resume
(
segment
)
Resumes the TestRunner after wait() was called.
- Parameters:
-
segment
<Function>
The function to run as the rest
of the haulted test.
static
Void
run
(
oldMode
)
Runs the test suite.
- Parameters:
-
oldMode
<Boolean>
(Optional) Specifies that the <= 2.8 way of
internally managing test suites should be used.
Void
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
<String>
The name of the result set.
Events
begin
(
)
Fires when the run() method is called.
complete
(
)
Fires when all test suites and test cases have been completed.
fail
(
)
Fires when a test has failed.
ignore
(
)
Fires when a test has been ignored.
pass
(
)
Fires when a test has passed.
testcasebegin
(
)
Fires when a test case is opened but before the first
test is executed.
testcasecomplete
(
)
Fires when all tests in a test case have been executed.
testsuitebegin
(
)
Fires when a test suite is opened but before the first
test is executed.
testsuitecomplete
(
)
Fires when all test cases in a test suite have been
completed.