Interface TestExecutionListener

    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void afterAll​(EventContext context)
      IMPORTANT: this method MIGHT NOT BE CALLED at all in case if extension is registered under non-static field (and so the application is stopped after each method).
      default void afterEach​(EventContext context)
      Called after each test method execution.
      default void beforeAll​(EventContext context)
      IMPORTANT: this method MIGHT NOT BE CALLED at all in case if extension is registered under non-static field (and so application created before each method).
      default void beforeEach​(EventContext context)
      Called before each test method execution.
      default void started​(EventContext context)
      Called when dropwizard (or guicey) application started.
      default void starting​(EventContext context)
      Called before dropwizard (or guicey) application starting.
      default void stopped​(EventContext context)
      Called when dropwizard (or guicey) application stopped.
      default void stopping​(EventContext context)
      Called before dropwizard (or guicey) application stopping.
    • Method Detail

      • starting

        default void starting​(EventContext context)
                       throws java.lang.Exception
        Called before dropwizard (or guicey) application starting. It could be beforeAll or beforeEach phase (if important, look ExtensionContext.getTestMethod() to make sure). Application could start/stop multiple times within one test class (if extension registered in non-static field).

        NOTE: At this stage, injections not yet performed inside test instance.

        This method could be used instead of beforeAll because normally extension is created under beforeAll, but for extensions created under beforeEach - it would be impossible to notify about beforeAll anyway.

        Parameters:
        context - context object providing access to all available objects (junit context, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • started

        default void started​(EventContext context)
                      throws java.lang.Exception
        Called when dropwizard (or guicey) application started. It could be beforeAll or beforeEach phase (if important, look ExtensionContext.getTestMethod() to make sure). Application could start/stop multiple times within one test class (if extension registered in non-static field).

        NOTE: At this stage, injections not yet performed inside test instance.

        This method could be used instead of beforeAll because normally extension is created under beforeAll, but for extensions created under beforeEach - it would be impossible to notify about beforeAll anyway.

        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • beforeAll

        default void beforeAll​(EventContext context)
                        throws java.lang.Exception
        IMPORTANT: this method MIGHT NOT BE CALLED at all in case if extension is registered under non-static field (and so application created before each method). Prefer started(ru.vyarus.dropwizard.guice.test.jupiter.env.listen.EventContext) instead, which is always called (but not always under beforeAll),

        Method could be useful if some action must be performed before each test (in case of nested tests or global application when "start" would not be called for each test).

        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • beforeEach

        default void beforeEach​(EventContext context)
                         throws java.lang.Exception
        Called before each test method execution. Guice injections into test instance already performed. Even if an application is created in beforeEach phase, this method would be called after application creation.
        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • afterEach

        default void afterEach​(EventContext context)
                        throws java.lang.Exception
        Called after each test method execution. Even if an application is closed on afterEach, this method would be called before it.
        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • afterAll

        default void afterAll​(EventContext context)
                       throws java.lang.Exception
        IMPORTANT: this method MIGHT NOT BE CALLED at all in case if extension is registered under non-static field (and so the application is stopped after each method). Prefer stopped(ru.vyarus.dropwizard.guice.test.jupiter.env.listen.EventContext) instead, which is always called (but not always under afterAll),

        Method could be useful if some action must be performed after each test (in case of nested tests or global application when "stop" would not be called for each test).

        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • stopping

        default void stopping​(EventContext context)
                       throws java.lang.Exception
        Called before dropwizard (or guicey) application stopping. It could be afterAll or afterEach phase (if important, look ExtensionContext.getTestMethod() to make sure). Application could start/stop multiple times within one test class (if extension registered in non-static field).

        Note that in case of global application usage or for nested tests this method might not be called because application lifecycle would be managed by the top-most test.

        This method could be used instead of afterAll because normally extension is stopped under afterAll, but for extensions stopped under afterEach - it would be impossible to notify about afterAll anyway.

        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error
      • stopped

        default void stopped​(EventContext context)
                      throws java.lang.Exception
        Called when dropwizard (or guicey) application stopped. It could be afterAll or afterEach phase (if important, look ExtensionContext.getTestMethod() to make sure). Application could start/stop multiple times within one test class (if extension registered in non-static field).

        Note that in case of global application usage or for nested tests this method might not be called because application lifecycle would be managed by the top-most test.

        This method could be used instead of afterAll because normally extension is stopped under afterAll, but for extensions stopped under afterEach - it would be impossible to notify about afterAll anyway.

        Parameters:
        context - context object providing access to all required objects (junit context, injector, test support, etc.)
        Throws:
        java.lang.Exception - on error