Package io.vertx.junit5

## Class RunTestOnContext

- java.lang.Object
- - io.vertx.junit5.RunTestOnContext

- All Implemented Interfaces:
    `org.junit.jupiter.api.extension.AfterAllCallback`, `org.junit.jupiter.api.extension.AfterEachCallback`, `org.junit.jupiter.api.extension.BeforeAllCallback`, `org.junit.jupiter.api.extension.Extension`, `org.junit.jupiter.api.extension.InvocationInterceptor`

      public class RunTestOnContext
      extends Object
      implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.InvocationInterceptor, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback

  An extension that runs tests on a Vert.x context.

  When used as a `RegisterExtension` instance field, a new `Vertx` object and `Context` are created for each tested method. `BeforeEach` and `AfterEach` methods are executed on this context.

  When used as a `RegisterExtension` static field, a single `Vertx` object and `Context` are created for all the tested methods. `BeforeAll` and `AfterAll` methods are executed on this context too.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor

      `org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T extends Object>`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RunTestOnContext()` | Create an instance of this extension that builds a `Vertx` object using default options.
    `RunTestOnContext​(VertxOptions options, boolean clustered)` | Create an instance of this extension that builds a `Vertx` object using the specified `options`.
    `RunTestOnContext​(Supplier<Future<Vertx>> supplier)` | Create an instance of this extension that gets a `Vertx` object using the specified asynchronous `supplier`.
    `RunTestOnContext​(Supplier<Future<Vertx>> supplier, Function<Vertx,​Future<Void>> shutdown)` | Create an instance of this extension that gets a `Vertx` object using the specified asynchronous `supplier`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)` |
    `void` | `afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)` |
    `void` | `beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)` |
    `void` | `interceptAfterAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `void` | `interceptAfterEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `void` | `interceptBeforeAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `void` | `interceptBeforeEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `void` | `interceptDynamicTest​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `<T> T` | `interceptTestFactoryMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `void` | `interceptTestMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `void` | `interceptTestTemplateMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)` |
    `Vertx` | `vertx()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor

      `interceptDynamicTest, interceptTestClassConstructor`

- - ### Constructor Detail

    - #### RunTestOnContext

          public RunTestOnContext()

      Create an instance of this extension that builds a `Vertx` object using default options.

    - #### RunTestOnContext

          public RunTestOnContext​(VertxOptions options,
                                  boolean clustered)

      Create an instance of this extension that builds a `Vertx` object using the specified `options`.

      When the options hold a `ClusterManager` instance, a clustered `Vertx` object is created.

      Parameters:
        `options` - the vertx options

    - #### RunTestOnContext

          public RunTestOnContext​(Supplier<Future<Vertx>> supplier)

      Create an instance of this extension that gets a `Vertx` object using the specified asynchronous `supplier`.
      Parameters:
        `supplier` - the asynchronous supplier

    - #### RunTestOnContext

          public RunTestOnContext​(Supplier<Future<Vertx>> supplier,
                                  Function<Vertx,​Future<Void>> shutdown)

      Create an instance of this extension that gets a `Vertx` object using the specified asynchronous `supplier`. The asynchronous `shutdown` function is invoked when the `Vertx` object is no longer needed.
      Parameters:
        `supplier` - the asynchronous supplier
        `shutdown` - the asynchronous shutdown function

  - ### Method Detail

    - #### vertx

          public Vertx vertx()

      Returns:
        the current Vert.x instance

    - #### beforeAll

          public void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)

      Specified by:
        `beforeAll` in interface `org.junit.jupiter.api.extension.BeforeAllCallback`

    - #### interceptBeforeAllMethod

          public void interceptBeforeAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                               org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                               org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                        throws Throwable

      Specified by:
        `interceptBeforeAllMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptBeforeEachMethod

          public void interceptBeforeEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                                org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                                org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                         throws Throwable

      Specified by:
        `interceptBeforeEachMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptTestMethod

          public void interceptTestMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                          org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                          org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                   throws Throwable

      Specified by:
        `interceptTestMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptTestFactoryMethod

          public <T> T interceptTestFactoryMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation,
                                                  org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                                  org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                           throws Throwable

      Specified by:
        `interceptTestFactoryMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptTestTemplateMethod

          public void interceptTestTemplateMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                                  org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                                  org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                           throws Throwable

      Specified by:
        `interceptTestTemplateMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptDynamicTest

          public void interceptDynamicTest​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                           org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                    throws Throwable

      Specified by:
        `interceptDynamicTest` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptAfterEachMethod

          public void interceptAfterEachMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                               org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                               org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                        throws Throwable

      Specified by:
        `interceptAfterEachMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### interceptAfterAllMethod

          public void interceptAfterAllMethod​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation,
                                              org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext,
                                              org.junit.jupiter.api.extension.ExtensionContext extensionContext)
                                       throws Throwable

      Specified by:
        `interceptAfterAllMethod` in interface `org.junit.jupiter.api.extension.InvocationInterceptor`
      Throws:
        `Throwable`

    - #### afterEach

          public void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                         throws Exception

      Specified by:
        `afterEach` in interface `org.junit.jupiter.api.extension.AfterEachCallback`
      Throws:
        `Exception`

    - #### afterAll

          public void afterAll​(org.junit.jupiter.api.extension.ExtensionContext context)
                        throws Exception

      Specified by:
        `afterAll` in interface `org.junit.jupiter.api.extension.AfterAllCallback`
      Throws:
        `Exception`