Class TestGuiceyAppExtension.Builder

    • Constructor Detail

      • Builder

        public Builder​(java.lang.Class<? extends io.dropwizard.Application> app)
    • Method Detail

      • setup

        @SafeVarargs
        public final TestGuiceyAppExtension.Builder setup​(java.lang.Class<? extends TestEnvironmentSetup>... support)
        Environment support objects is the simplest mechanism to prepare additional objects for test (like database) and apply configuration overrides. Provided classes would be instantiated with the default constructor.

        To avoid confusion with guicey hooks: setup object required to prepare test environment before test (and apply required configurations) whereas hooks is a general mechanism for application customization (not only in tests).

        Anonymous implementation could be simply declared as field: @EnableSetup static TestEnvironmentSetup ext = ext -> ext.configOverrides("foo:1"). Non-static fields may be used only when extension is registered with non-static field (static fields would be also counted in this case). All annotated fields will be detected automatically and objects registered. Fields declared in base test classes are also counted.

        Parameters:
        support - support object classes
        Returns:
        builder instance for chained calls
      • setup

        public TestGuiceyAppExtension.Builder setup​(TestEnvironmentSetup... support)
        Environment support objects is the simplest mechanism to prepare additional objects for test (like database) and apply configuration overrides.

        To avoid confusion with guicey hooks: setup object required to prepare test environment before test (and apply required configurations) whereas hooks is a general mechanism for application customization (not only in tests).

        Anonymous implementation could be simply declared as field: @EnableSetup static TestEnvironmentSetup ext = ext -> ext.configOverrides("foo:1"). Non-static fields may be used only when extension is registered with non-static field (static fields would be also counted in this case). All annotated fields will be detected automatically and objects registered. Fields declared in base test classes are also counted.

        Parameters:
        support - support object instances
        Returns:
        builder instance for chained calls
      • create

        public TestGuiceyAppExtension create()
        Creates extension.

        Note that extension must be assigned to static field! Extension instance does not provide additional methods so use field and parameter injections as with annotation extension declaration.

        Returns:
        extension instance