Interface TestSupportBuilder.TestListener<C extends io.dropwizard.core.Configuration>

Type Parameters:
C - configuration type
Enclosing class:
TestSupportBuilder<C extends io.dropwizard.core.Configuration>

public static interface TestSupportBuilder.TestListener<C extends io.dropwizard.core.Configuration>
Listener for TestSupport.build(Class) builder. Listener works only when builder run method used! Useful for test-specific setup and cleanup. Note that GuiceyTestSupport extends DropwizardTestSupport. Guicey support object does not provide any useful methods (in context of the builder), so it is appropriate to always use dropwizard support object.

See TestSupport utility methods if something guice-related is required. To access web client use TestSupport.getContextClient()

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    cleanup(io.dropwizard.testing.DropwizardTestSupport<C> support)
    Called after application shutdown (including startup error case).
    default void
    run(io.dropwizard.testing.DropwizardTestSupport<C> support, com.google.inject.Injector injector)
    An application started, but test logic was not executed yet.
    default void
    setup(io.dropwizard.testing.DropwizardTestSupport<C> support)
    Called before application startup.
    default void
    stop(io.dropwizard.testing.DropwizardTestSupport<C> support, com.google.inject.Injector injector)
    Called after test action (or after exception during action execution), but before application shutdown.
  • Method Details

    • setup

      default void setup(io.dropwizard.testing.DropwizardTestSupport<C> support) throws Exception
      Called before application startup.
      Parameters:
      support - initialized support object (not started)
      Throws:
      Exception - any errors pass through
    • run

      default void run(io.dropwizard.testing.DropwizardTestSupport<C> support, com.google.inject.Injector injector) throws Exception
      An application started, but test logic was not executed yet. Will not be called in case of application startup error.

      ClientSupport web client could be accessed with TestSupport.getContextClient().

      Parameters:
      support - started support object
      injector - injector instance
      Throws:
      Exception - any errors pass through
    • stop

      default void stop(io.dropwizard.testing.DropwizardTestSupport<C> support, com.google.inject.Injector injector) throws Exception
      Called after test action (or after exception during action execution), but before application shutdown.

      ClientSupport web client could be accessed with TestSupport.getContextClient().

      Parameters:
      support - still started suport object
      injector - injector instance
      Throws:
      Exception - any errors pass through
    • cleanup

      default void cleanup(io.dropwizard.testing.DropwizardTestSupport<C> support) throws Exception
      Called after application shutdown (including startup error case).
      Parameters:
      support - stopped support object
      Throws:
      Exception - any errors pass through