vertx / io.vertx.junit5 / VertxTestContext

VertxTestContext

class VertxTestContext

A test context to wait on the outcomes of asynchronous operations.

Author
Julien Ponge

Constructors

<init>

VertxTestContext()

A test context to wait on the outcomes of asynchronous operations.

Functions

awaitCompletion

fun awaitCompletion(timeout: Long, unit: TimeUnit): Boolean

Wait for the completion of the test context.

This method is automatically called by the VertxExtension when using parameter injection of VertxTestContext. You should only call it when you instantiate this class manually.

causeOfFailure

fun causeOfFailure(): Throwable

Give the cause of failure.

checkpoint

fun checkpoint(): Checkpoint
fun checkpoint(requiredNumberOfPasses: Int): Checkpoint

Create a checkpoint.

completeNow

fun completeNow(): Unit

Complete the test context immediately, making the corresponding test pass.

completed

fun completed(): Boolean

Check if the context has completed.

failNow

fun failNow(t: Throwable): Unit

Make the test context fail immediately, making the corresponding test fail.

failed

fun failed(): Boolean

Check if the context has been marked has failed or not.

failing

fun <T : Any> failing(): Handler<AsyncResult<T>>

Create an asynchronous result handler that expects a failure.

fun <T : Any> failing(nextHandler: Handler<Throwable>): Handler<AsyncResult<T>>

Create an asynchronous result handler that expects a failure, and passes the exception to another handler.

strictCheckpoint

fun strictCheckpoint(): Checkpoint
fun strictCheckpoint(requiredNumberOfPasses: Int): Checkpoint

Create a strict checkpoint.

succeeding

fun <T : Any> succeeding(): Handler<AsyncResult<T>>

Create an asynchronous result handler that expects a success.

fun <T : Any> succeeding(nextHandler: Handler<T>): Handler<AsyncResult<T>>

Create an asynchronous result handler that expects a success, and passes the value to another handler.

verify

fun verify(block: Runnable): VertxTestContext

Allow verifications and assertions to be made.

This method allows any assertion API to be used. The semantic is that the verification is successful when no exception is being thrown upon calling block, otherwise the context fails with that exception.