static
Class Test.Runner
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.
_log
- private static Boolean
Indicates if the TestRunner will log events or not.
_root
- private static TestNode
Pointer to the root node in the test tree.
_waiting
- private static Boolean
Indicates if the TestRunner is waiting as a result of
wait() being called.
masterSuite
- private static Y.Test.Suite
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
<Y.Test.Case>
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
<Y.Test.Suite>
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
_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
<Error>
The error object.
private
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
Void
_logEvent
(
event
)
Logs TestRunner events using Y.log().
- Parameters:
-
event
<Object>
The event object for the event.
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
<Y.Test.Case|Y.Test.Suite>
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.
static
Void
disableLogging
(
)
Disable logging via Y.log(). Test output will not be visible unless
TestRunner events are subscribed to.
static
Void
enableLogging
(
)
Enable logging via Y.log(). Test output is published and can be read via
logreader.
static
Boolean
isWaiting
(
)
Indicates if the TestRunner is waiting for a test to resume
- Returns:
Boolean
- True if the TestRunner is waiting, 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
(
)
Runs the test suite.
Events
static
begin
(
)
Fires when the run() method is called.
static
complete
(
)
Fires when all test suites and test cases have been completed.
static
fail
(
)
Fires when a test has failed.
static
ignore
(
)
Fires when a test has been ignored.
static
pass
(
)
Fires when a test has passed.
static
testcasebegin
(
)
Fires when a test case is opened but before the first
test is executed.
static
testcasecomplete
(
)
Fires when all tests in a test case have been executed.
static
testsuitebegin
(
)
Fires when a test suite is opened but before the first
test is executed.
static
testsuitecomplete
(
)
Fires when all test cases in a test suite have been
completed.