#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# Test.TestCase Class

Defined in: `test/js/TestCase.js:1`
Module: test

Test case containing various tests to run.

- Index
- Methods

## Item Index

### Methods

- assert
- callback
- destroy
- fail
- init
- resume
- setUp
- tearDown
- wait

## Methods

### `assert`

(

- `condition`
- `message`

)

Defined in `test/js/TestCase.js:90`

Asserts that a given condition is true. If not, then a YUITest.AssertionError object is thrown and the test fails.

#### Parameters:

- `condition` Boolean

  The condition to test.

- `message` String

  The message to display if the assertion fails.

### `callback`

() Function

Defined in `test/js/TestCase.js:40`

Method to call from an async init method to restart the test case. When called, returns a function that should be called when tests are ready to continue.

#### Returns:

Function: The function to call as a callback.

### `destroy`

()

Defined in `test/js/TestCase.js:126`

Function to run once after tests finish running. This executes after the last call to tearDown().

### `fail`

(

- `message`

)

Defined in `test/js/TestCase.js:104`

Forces an assertion error to occur. Shortcut for YUITest.Assert.fail().

#### Parameters:

- `message` String

  (Optional) The message to display with the failure.

### `init`

()

Defined in `test/js/TestCase.js:117`

Function to run once before tests start to run. This executes before the first call to setUp().

### `resume`

(

- `segment`

)
Void

Defined in `test/js/TestCase.js:51`

Resumes a paused test and runs the given function.

#### Parameters:

- `segment` Function

  (Optional) The function to run. If omitted, the test automatically passes.

#### Returns:

Void:

### `setUp`

() Void

Defined in `test/js/TestCase.js:135`

Function to run before each test is executed.

#### Returns:

Void:

### `tearDown`

() Void

Defined in `test/js/TestCase.js:144`

Function to run after each test is executed.

#### Returns:

Void:

### `wait`

(

- `segment`
- `delay`

)
Void

Defined in `test/js/TestCase.js:62`

Causes the test case to wait a specified amount of time and then continue executing the given code.

#### Parameters:

- `segment` Function

  (Optional) The function to run after the delay. If omitted, the TestRunner will wait until resume() is called.

- `delay` Int

  (Optional) The number of milliseconds to wait before running the function. If omitted, defaults to zero.

#### Returns:

Void: