# Yahoo! UI Library

### yuitest 2.5.1

Yahoo! UI Library > yuitest > YAHOO.tool.TestNode

Show Private Show Protected

## `private` Class YAHOO.tool.TestNode

A node in the test tree structure. May represent a TestSuite, TestCase, or test function.

### Constructor

YAHOO.tool.TestNode `( testObject )`

Parameters:
  `testObject <Variant>` A TestSuite, TestCase, or the name of a test function.

### Properties

#### _cur `- private TestNode`

Pointer to the current node in the test tree.

#### _root `- private TestNode`

Pointer to the root node in the test tree.

#### firstChild `- TestNode`

Pointer to this node's first child.

#### lastChild `- TestNode`

Pointer to this node's last child.

#### masterSuite `- private YAHOO.tool.TestSuite`

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

#### next `- TestNode`

Pointer to this node's next sibling.

#### parent `- TestNode`

Pointer to this node's parent.

#### results `- object`

Test results for this test object.

#### testObject `- Variant`

The TestSuite, TestCase, or test function represented by this node.

### Methods

#### _addTestCaseToTestTree

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

Returns: `Void`

#### _addTestSuiteToTestTree

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

Returns: `Void`

#### _buildTestTree

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

Returns: `Void`

#### _handleTestObjectComplete

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

Returns: `Void`

#### _next

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

#### _run

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

#### _runTest

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

Returns: `Void`

#### add

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

Returns: `Void`

#### appendChild

`Void appendChild ( testObject )`
Appends a new test object (TestSuite, TestCase, or test function name) as a child of this node.

Parameters:
  `testObject <Variant>` A TestSuite, TestCase, or the name of a test function.

Returns: `Void`

#### clear

`static Void clear ( )`
Removes all test objects from the runner.

Returns: `Void`

#### resume

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

Returns: `Void`

#### run

`static Void run ( )`
Runs the test suite.

Returns: `Void`

### Events

#### begin

`begin ( )`
Fires when the run() method is called.

#### complete

`complete ( )`
Fires when all test suites and test cases have been completed.

#### fail

`fail ( )`
Fires when a test has failed.

#### ignore

`ignore ( )`
Fires when a test has been ignored.

#### pass

`pass ( )`
Fires when a test has passed.

#### testcasebegin

`testcasebegin ( )`
Fires when a test case is opened but before the first test is executed.

#### testcasecomplete

`testcasecomplete ( )`
Fires when all tests in a test case have been executed.

#### testsuitebegin

`testsuitebegin ( )`
Fires when a test suite is opened but before the first test is executed.

#### testsuitecomplete

`testsuitecomplete ( )`
Fires when all test cases in a test suite have been completed.

Copyright © 2007 Yahoo! Inc. All rights reserved.