#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# Test.Runner Class

Defined in: `test/js/TestRunner.js:120`
Module: test

Runs test suites and test cases, providing events to allowing for the interpretation of test results.

- Index
- Methods
- Properties
- Events

## 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`

)
Void private static

Defined in `test/js/TestRunner.js:315`

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` Test.TestCase

  The test case to add.

#### Returns:

Void:

### `_addTestSuiteToTestTree`

(

- `parentNode`
- `testSuite`

)
Void private static

Defined in `test/js/TestRunner.js:340`

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` Test.TestSuite

  The test suite to add.

#### Returns:

Void:

### `_buildTestTree`

() Void private static

Defined in `test/js/TestRunner.js:364`

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:

Void:

### `_execNonTestMethod`

(

- `node`
- `methodName`
- `allowAsync`

)
Boolean private

Defined in `test/js/TestRunner.js:467`

Executes a non-test method (init, setUp, tearDown, destroy) and traps an errors. If an error occurs, an error event is fired.

#### Parameters:

- `node` Object

  The test node in the testing tree.

- `methodName` String

  The name of the method to execute.

- `allowAsync` Boolean

  Determines if the method can be called asynchronously.

#### Returns:

Boolean: True if an async method was called, false if not.

### `_handleError`

(

- `error`

)
Void private static

Defined in `test/js/TestRunner.js:739`

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.

#### Returns:

Void:

### `_handleTestObjectComplete`

(

- `node`

)
Void private

Defined in `test/js/TestRunner.js:393`

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.

#### Returns:

Void:

### `_next`

() TestNode private static

Defined in `test/js/TestRunner.js:428`

Retrieves the next node in the test tree.

#### Returns:

TestNode: The next node in the test tree or null if the end is reached.

### `_run`

(

- `testObject`

)
Object private static

Defined in `test/js/TestRunner.js:504`

Runs a test case or test suite, returning the results.

#### Parameters:

- `testObject` Test.TestCase | YUITest.TestSuite

  The test case or test suite to run.

#### Returns:

Object: Results of the execution with properties passed, failed, and total.

### `_runTest`

(

- `node`

)
Void private static

Defined in `test/js/TestRunner.js:764`

Runs a single test based on the data provided in the node.

#### Parameters:

- `node` TestNode

  The TestNode representing the test to run.

#### Returns:

Void:

### `add`

(

- `testObject`

)
Void static

Defined in `test/js/TestRunner.js:851`

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.

#### Returns:

Void:

### `callback`

() Function private

Defined in `test/js/TestRunner.js:943`

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:

Function: A callback function.

### `clear`

() Void static

Defined in `test/js/TestRunner.js:863`

Removes all test objects from the runner.

#### Returns:

Void:

### `getCoverage`

(

- `format`

)
Object | String

Defined in `test/js/TestRunner.js:914`

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.

### `getName`

() String

Defined in `test/js/TestRunner.js:827`

Retrieves the name of the current result set.

#### Returns:

String: The name of the result set.

### `getResults`

(

- `format`

)
Object | String

Defined in `test/js/TestRunner.js:893`

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.

### `isRunning`

() Boolean

Defined in `test/js/TestRunner.js:883`

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.

### `isWaiting`

() Boolean static

Defined in `test/js/TestRunner.js:873`

Indicates if the TestRunner is waiting for a test to resume

#### Returns:

Boolean: True if the TestRunner is waiting, false if not.

### `resume`

(

- `segment`

)
Void static

Defined in `test/js/TestRunner.js:967`

Resumes the TestRunner after wait() was called.

#### Parameters:

- `segment` Function

  The function to run as the rest of the haulted test.

#### Returns:

Void:

### `run`

(

- `options`

)
Void static

Defined in `test/js/TestRunner.js:983`

Runs the test suite.

#### Parameters:

- `options` Object | Boolean

  (Optional) Options for the runner: `oldMode` indicates the TestRunner should work in the YUI <= 2.8 way of internally managing test suites. `groups` is an array of test groups indicating which tests to run.

#### Returns:

Void:

### `setName`

(

- `name`

)
Void

Defined in `test/js/TestRunner.js:836`

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.

#### Returns:

Void:

## Properties

### `_cur`

TestNode private static

Defined in `test/js/TestRunner.js:142`

Pointer to the current node in the test tree.

### `_data`

Object private static

Defined in `test/js/TestRunner.js:198`

Data object that is passed around from method to method.

### `_groups`

String private static

Defined in `test/js/TestRunner.js:207`

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

Defined in `test/js/TestRunner.js:222`

If true, YUITest will not fire an error for tests with no Asserts.

### `_lastResults`

Object private static

Defined in `test/js/TestRunner.js:188`

Holds copy of the results object generated when all tests are complete.

### `_log`

Boolean private static

Defined in `test/js/TestRunner.js:160`

Indicates if the TestRunner will log events or not.

### `_root`

TestNode private static

Defined in `test/js/TestRunner.js:151`

Pointer to the root node in the test tree.

### `_running`

Boolean private static

Defined in `test/js/TestRunner.js:179`

Indicates if the TestRunner is currently running tests.

### `_waiting`

Boolean private static

Defined in `test/js/TestRunner.js:169`

Indicates if the TestRunner is waiting as a result of wait() being called.

### `masterSuite`

YUITest.TestSuite private static

Defined in `test/js/TestRunner.js:133`

Suite on which to attach all TestSuites and TestCases to be run.

## Events

### `begin`

static

Defined in `test/js/TestRunner.js:304`

Fires when the run() method is called.

### `complete`

static

Defined in `test/js/TestRunner.js:297`

Fires when all test suites and test cases have been completed.

### `error`

static

Defined in `test/js/TestRunner.js:283`

Fires when a non-test method has an error.

### `fail`

static

Defined in `test/js/TestRunner.js:276`

Fires when a test has failed.

### `ignore`

static

Defined in `test/js/TestRunner.js:290`

Fires when a test has been ignored.

### `pass`

static

Defined in `test/js/TestRunner.js:269`

Fires when a test has passed.

### `testcasebegin`

static

Defined in `test/js/TestRunner.js:238`

Fires when a test case is opened but before the first test is executed.

### `testcasecomplete`

static

Defined in `test/js/TestRunner.js:246`

Fires when all tests in a test case have been executed.

### `testsuitebegin`

static

Defined in `test/js/TestRunner.js:253`

Fires when a test suite is opened but before the first test is executed.

### `testsuitecomplete`

static

Defined in `test/js/TestRunner.js:261`

Fires when all test cases in a test suite have been completed.