Package: io.vertx.groovy.ext.unit

## [Groovy] Class TestContext

- io.vertx.groovy.ext.unit.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.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `TestContext (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `TestContext` | `assertEquals(java.lang.Object expected, java.lang.Object actual)` Assert the `expected` argument is equals to the `actual` argument.
    `TestContext` | `assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)` Assert the `expected` argument is equals to the `actual` argument.
    `TestContext` | `assertFalse(boolean condition)` Assert the specified `condition` is `false`.
    `TestContext` | `assertFalse(boolean condition, java.lang.String message)` Assert the specified `condition` is `false`.
    `TestContext` | `assertInRange(double expected, double actual, double delta)` Asserts that the `expected` double argument is equals to the `actual` double argument within a positive delta.
    `TestContext` | `assertInRange(double expected, double actual, double delta, java.lang.String message)` Asserts that the `expected` double argument is equals to the `actual` double argument within a positive delta.
    `TestContext` | `assertNotEquals(java.lang.Object first, java.lang.Object second)` Assert the `first` argument is not equals to the `second` argument.
    `TestContext` | `assertNotEquals(java.lang.Object first, java.lang.Object second, java.lang.String message)` Assert the `first` argument is not equals to the `second` argument.
    `TestContext` | `assertNotNull(java.lang.Object expected)` Assert the `expected` argument is not `null`.
    `TestContext` | `assertNotNull(java.lang.Object expected, java.lang.String message)` Assert the `expected` argument is not `null`.
    `TestContext` | `assertNull(java.lang.Object expected)` Assert the `expected` argument is `null`.
    `TestContext` | `assertNull(java.lang.Object expected, java.lang.String message)` Assert the `expected` argument is `null`.
    `TestContext` | `assertTrue(boolean condition)` Assert the specified `condition` is `true`.
    `TestContext` | `assertTrue(boolean condition, java.lang.String message)` Assert the specified `condition` is `true`.
    `Async` | `async()` Create and returns a new async object, the returned async controls the completion of the test.
    `Async` | `async(int count)` Create and returns a new async object, the returned async controls the completion of the test.
    `io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>` | `asyncAssertFailure()` Creates and returns a new async handler, the returned handler controls the completion of the test.
    `io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>` | `asyncAssertFailure(io.vertx.core.Handler<java.lang.Throwable> causeHandler)` Creates and returns a new async handler, the returned handler controls the completion of the test.
    `io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>` | `asyncAssertSuccess()` Creates and returns a new async handler, the returned handler controls the completion of the test.
    `io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>` | `asyncAssertSuccess(io.vertx.core.Handler<T> resultHandler)` Creates and returns a new async handler, the returned handler controls the completion of the test.
    `io.vertx.core.Handler<java.lang.Throwable>` | `exceptionHandler()` @return an exception handler that will fail this context
    `void` | `fail()` Throw a failure.
    `void` | `fail(java.lang.String message)` Throw a failure with the specified failure `message`.
    `void` | `fail(java.lang.Throwable cause)` Throw a failure with the specified failure `cause`.
    `T` | `get(java.lang.String key)` Get some data from the context.
    `java.lang.Object` | `getDelegate()`
    `T` | `put(java.lang.String key, java.lang.Object value)` Put some data in the context.
    `T` | `remove(java.lang.String key)` Remove some data from the context.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### TestContext(java.lang.Object delegate)

  - ### Method Detail

    - #### TestContext assertEquals(java.lang.Object expected, java.lang.Object actual)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the object the actual object is supposedly equals to
        `actual` - the actual object to test

    - #### TestContext assertEquals(java.lang.Object expected, java.lang.Object actual, java.lang.String message)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the object the actual object is supposedly equals to
        `actual` - the actual object to test
        `message` - the failure message

    - #### TestContext assertFalse(boolean condition)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `condition` - the condition to assert

    - #### TestContext assertFalse(boolean condition, java.lang.String message)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `condition` - the condition to assert
        `message` - the failure message

    - #### TestContext assertInRange(double expected, double actual, double delta)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the object the actual object is supposedly equals to
        `actual` - the actual object to test
        `delta` - the maximum delta

    - #### TestContext assertInRange(double expected, double actual, double delta, java.lang.String message)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the object the actual object is supposedly equals to
        `actual` - the actual object to test
        `delta` - the maximum delta
        `message` - the failure message

    - #### TestContext assertNotEquals(java.lang.Object first, java.lang.Object second)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `first` - the first object to test
        `second` - the second object to test

    - #### TestContext assertNotEquals(java.lang.Object first, java.lang.Object second, java.lang.String message)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `first` - the first object to test
        `second` - the second object to test
        `message` - the failure message

    - #### TestContext assertNotNull(java.lang.Object expected)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the argument being asserted to be not null

    - #### TestContext assertNotNull(java.lang.Object expected, java.lang.String message)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the argument being asserted to be not null
        `message` - the failure message

    - #### TestContext assertNull(java.lang.Object expected)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the argument being asserted to be null

    - #### TestContext assertNull(java.lang.Object expected, java.lang.String message)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `expected` - the argument being asserted to be null
        `message` - the failure message

    - #### TestContext assertTrue(boolean condition)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `condition` - the condition to assert

    - #### TestContext assertTrue(boolean condition, java.lang.String message)

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

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `condition` - the condition to assert
        `message` - the failure message

    - #### 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.
      Returns:
        the async instance

    - #### Async async(int count)

      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.

      Returns:
        the async instance
      Parameters:
        count

    - #### io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> asyncAssertFailure()

      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.

      Returns:
        the async result handler

    - #### io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> asyncAssertFailure(io.vertx.core.Handler<java.lang.Throwable> causeHandler)

      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.

      Returns:
        the async result handler
      Parameters:
        `causeHandler` - the cause handler

    - #### io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> asyncAssertSuccess()

      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 completes the async operation.

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

      Returns:
        the async result handler

    - #### io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> asyncAssertSuccess(io.vertx.core.Handler<T> resultHandler)

      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.
      Returns:
        the async result handler
      Parameters:
        `resultHandler` - the result handler

    - #### io.vertx.core.Handler<java.lang.Throwable> exceptionHandler()

      Returns:
        an exception handler that will fail this context

    - #### void fail()

      Throw a failure.

    - #### void fail(java.lang.String message)

      Throw a failure with the specified failure `message`.

      Parameters:
        `message` - the failure message

    - #### void fail(java.lang.Throwable cause)

      Throw a failure with the specified failure `cause`.

      Parameters:
        `cause` - the failure cause

    - #### T get(java.lang.String key)

      Get some data from the context.

      Returns:
        the data
      Parameters:
        `key` - the key of the data

    - #### java.lang.Object getDelegate()

    - #### T put(java.lang.String key, java.lang.Object value)

      Put some data in the context.

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

      Returns:
        the previous object when it exists
      Parameters:
        `key` - the key of the data
        `value` - the data

    - #### T remove(java.lang.String key)

      Remove some data from the context.

      Returns:
        the removed object when it exists
      Parameters:
        `key` - the key to remove