vertx / io.vertx.ext.unit.junit / RunTestOnContext

RunTestOnContext

open class RunTestOnContext : TestRule

A JUnit rule that runs tests on a Vert.x context. When used as a org.junit.Rule a new context is created for each tested method, the context will be same for the before and after method, but different for all the tested methods. When used as a org.junit.ClassRule, a single context is created for all the tested method, the beforeClass and afterClass method will also executed in this context.

Author
Julien Viet

Constructors

<init>

RunTestOnContext()

Create a new rule managing a Vertx instance created with default options. The Vert.x instance is created and closed for each test.

RunTestOnContext(options: VertxOptions)

Create a new rule managing a Vertx instance created with specified options. The Vert.x instance is created and closed for each test.

RunTestOnContext(createVertx: Supplier<Vertx>, closeVertx: BiConsumer<Vertx, Consumer<Void>>)

Create a new rule with supplier/consumer for creating/closing a Vert.x instance. The lambda are invoked for each test. The closeVertx lambda should invoke the consumer with null when the vertx instance is closed.

RunTestOnContext(createVertx: Supplier<Vertx>)

Create a new rule with supplier for creating a Vert.x instance. The lambda are invoked for each test.

Functions

apply

open fun apply(base: Statement, description: Description): Statement

vertx

open fun vertx(): Vertx

Retrieves the current Vert.x instance, this value varies according to the test life cycle.