# Class: TestContext

## vertx-unit-js/test_context~ TestContext

#### new TestContext()

The test context is used for performing test assertions and manage the completion of the test. This context is provided by vertx-unit as argument of the test case.

Source:
  - vertx-unit-js/test_context.js, line 31

### Methods

#### assertEquals(expected, actual, message) → {TestContext}

Assert the `expected` argument is equals to the `actual` argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`expected` | Object | the object the actual object is supposedly equals to
`actual` | Object | the actual object to test
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 171

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### assertFalse(condition, message) → {TestContext}

Assert the specified `condition` is `false`. If the condition is `true`, an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`condition` | boolean | the condition to assert
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 150

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### assertInRange(expected, actual, delta, message) → {TestContext}

Asserts that the `expected` double argument is equals to the `actual` double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`expected` | number | the object the actual object is supposedly equals to
`actual` | number | the actual object to test
`delta` | number | the maximum delta
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 194

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### assertNotEquals(first, second, message) → {TestContext}

Assert the `first` argument is not equals to the `second` argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`first` | Object | the first object to test
`second` | Object | the second object to test
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 215

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### assertNotNull(expected, message) → {TestContext}

Assert the `expected` argument is not `null`. If the argument is `null`, an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`expected` | Object | the argument being asserted to be not null
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 110

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### assertNull(expected, message) → {TestContext}

Assert the `expected` argument is `null`. If the argument is not, an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`expected` | Object | the argument being asserted to be null
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 90

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### assertTrue(condition, message) → {TestContext}

Assert the specified `condition` is `true`. If the condition is `false`, an assertion error is thrown otherwise the execution continue.

##### Parameters:

Name | Type | Description
--- | --- | ---
`condition` | boolean | the condition to assert
`message` | string | the failure message

Source:
  - vertx-unit-js/test_context.js, line 130

##### Returns:

a reference to this, so the API can be used fluently

Type
  TestContext

#### async(count) → {Async}

Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when the Async#complete is called `count` times.

The test case will complete when all the async objects have their Async#complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

##### Parameters:

Name | Type | Description
--- | --- | ---
`count` | number |

Source:
  - vertx-unit-js/test_context.js, line 256

##### Returns:

the async instance

Type
  Async

#### asyncAssertFailure(causeHandler) → {function}

Creates and returns a new async handler, the returned handler controls the completion of the test.

When the returned handler is called back with a failed result it completes the async operation.

When the returned handler is called back with a succeeded result it fails the test.

##### Parameters:

Name | Type | Description
--- | --- | ---
`causeHandler` | function | the cause handler

Source:
  - vertx-unit-js/test_context.js, line 302

##### Returns:

the async result handler

Type
  function

#### asyncAssertSuccess(resultHandler) → {function}

Creates and returns a new async handler, the returned handler controls the completion of the test.

When the returned handler is called back with a succeeded result it invokes the `resultHandler` argument with the async result. The test completes after the result handler is invoked and does not fails.

When the returned handler is called back with a failed result it fails the test with the cause of the failure.

Note that the result handler can create other async objects during its invocation that would postpone the completion of the test case until those objects are resolved.

##### Parameters:

Name | Type | Description
--- | --- | ---
`resultHandler` | function | the result handler

Source:
  - vertx-unit-js/test_context.js, line 280

##### Returns:

the async result handler

Type
  function

#### exceptionHandler() → {function}

Source:
  - vertx-unit-js/test_context.js, line 320

##### Returns:

- an exception handler that will fail this context
- Type
    function

#### fail(cause)

Throw a failure with the specified failure `cause`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`cause` | todo | the failure cause

Source:
  - vertx-unit-js/test_context.js, line 232

#### get(key) → {Object}

Get some data from the context.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | the key of the data

Source:
  - vertx-unit-js/test_context.js, line 43

##### Returns:

the data

Type
  Object

#### put(key, value) → {Object}

Put some data in the context.

This can be used to share data between different tests and before/after phases.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | the key of the data
`value` | Object | the data

Source:
  - vertx-unit-js/test_context.js, line 60

##### Returns:

the previous object when it exists

Type
  Object

#### remove(key) → {Object}

Remove some data from the context.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | string | the key to remove

Source:
  - vertx-unit-js/test_context.js, line 74

##### Returns:

the removed object when it exists

Type
  Object