Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • TestContext

Index

Methods

assertEquals

  • assertEquals(expected: any, actual: any): TestContext
  • assertEquals(expected: any, actual: any, message: string): 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

    • expected: any
    • actual: any

    Returns 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

    • expected: any
    • actual: any
    • message: string

    Returns TestContext

assertFalse

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

    Parameters

    • condition: boolean

    Returns TestContext

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

    Parameters

    • condition: boolean
    • message: string

    Returns TestContext

assertInRange

  • assertInRange(expected: number, actual: number, delta: number): TestContext
  • assertInRange(expected: number, actual: number, delta: number, message: string): 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

    • expected: number
    • actual: number
    • delta: number

    Returns 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

    • expected: number
    • actual: number
    • delta: number
    • message: string

    Returns TestContext

assertNotEquals

  • assertNotEquals(first: any, second: any): TestContext
  • assertNotEquals(first: any, second: any, message: string): 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

    • first: any
    • second: any

    Returns 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

    • first: any
    • second: any
    • message: string

    Returns TestContext

assertNotNull

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

    Parameters

    • expected: any

    Returns TestContext

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

    Parameters

    • expected: any
    • message: string

    Returns TestContext

assertNull

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

    Parameters

    • expected: any

    Returns TestContext

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

    Parameters

    • expected: any
    • message: string

    Returns TestContext

assertTrue

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

    Parameters

    • condition: boolean

    Returns TestContext

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

    Parameters

    • condition: boolean
    • message: string

    Returns TestContext

async

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

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

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

    Returns Async

  • Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when the {@link Async#countDown} is called count times.

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

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

    Parameters

    • count: number

    Returns Async

asyncAssertFailure

  • asyncAssertFailure<T>(): ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>
  • asyncAssertFailure<T>(causeHandler: ((res: Throwable) => void) | Handler<Throwable>): ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>
  • 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.

    Type parameters

    • T

    Returns ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

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

    Type parameters

    • T

    Parameters

    • causeHandler: ((res: Throwable) => void) | Handler<Throwable>

    Returns ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

asyncAssertSuccess

  • asyncAssertSuccess<T>(): ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>
  • asyncAssertSuccess<T>(resultHandler: ((res: T) => void) | Handler<T>): ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>
  • 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.

    Type parameters

    • T

    Returns ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

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

    Type parameters

    • T

    Parameters

    • resultHandler: ((res: T) => void) | Handler<T>

    Returns ((res: AsyncResult<T>) => void) | Handler<AsyncResult<T>>

exceptionHandler

  • exceptionHandler(): ((res: Throwable) => void) | Handler<Throwable>
  • Returns ((res: Throwable) => void) | Handler<Throwable>

fail

  • fail(): void
  • fail(message: string): void
  • fail(cause: Throwable | Error): void
  • Throw a failure.

    Returns void

  • Throw a failure with the specified failure message.

    Parameters

    • message: string

    Returns void

  • Throw a failure with the specified failure cause.

    Parameters

    • cause: Throwable | Error

    Returns void

get

  • get<T>(key: string): T
  • Get some data from the context.

    Type parameters

    • T

    Parameters

    • key: string

    Returns T

put

  • put<T>(key: string, value: any): T
  • Put some data in the context.

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

    Type parameters

    • T

    Parameters

    • key: string
    • value: any

    Returns T

remove

  • remove<T>(key: string): T
  • Remove some data from the context.

    Type parameters

    • T

    Parameters

    • key: string

    Returns T

strictAsync

  • strictAsync(count: number): Async
  • Create and returns a new async object, the returned async controls the completion of the test. This async operation completes when the {@link Async#countDown} is called count times.

    If {@link Async#countDown} is called more than count times, an IllegalStateException is thrown.

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

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

    Parameters

    • count: number

    Returns Async

verify

  • verify(block: ((res: void) => void) | Handler<void>): TestContext
  • Execute the provided handler, which may contain assertions, possibly from any third-party assertion framework. Any AssertionError thrown will be caught (and propagated) in order to fulfill potential expected async completeness.

    Parameters

    • block: ((res: void) => void) | Handler<void>

    Returns TestContext

Generated using TypeDoc