# 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:
    - 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:
    - 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:
    - 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:
    - 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:
    - 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:
    - 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:
    - 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:
    - test_context.js, line 130

  ##### Returns:

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

#### async() → {Async}

  Create and returns a new async object, the returned async controls the completion of the test. Calling the Async#complete completes the async operation.

  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.
  Source:
    - test_context.js, line 256

  ##### Returns:

  the async instance
  Type
    Async

#### fail(cause)

  Throw a failure with the specified failure `cause`.

  ##### Parameters:

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

  Source:
    - 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:
    - 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:
    - 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:
    - test_context.js, line 74

  ##### Returns:

  the removed object when it exists
  Type
    Object