Class TestGuiceyAppExtension.Builder<C extends io.dropwizard.core.Configuration>
- Type Parameters:
C- configuration type (resolved automatically by application clas
- Enclosing class:
- TestGuiceyAppExtension
TestGuiceyAppExtension.forApp(Class)).-
Field Summary
Fields inherited from class ru.vyarus.dropwizard.guice.test.jupiter.ext.conf.ExtensionBuilder
cfg -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSame asTestGuiceyApp.config().create()Creates extension.By default, guicey simulatesManagedandLifeCyclelifecycle.final TestGuiceyAppExtension.Builder<C>setup(Class<? extends TestEnvironmentSetup>... support) Environment support objects is the simplest mechanism to prepare additional objects for test (like database) and apply configuration overrides.setup(TestEnvironmentSetup... support) Environment support objects is the simplest mechanism to prepare additional objects for test (like database) and apply configuration overrides.Methods inherited from class ru.vyarus.dropwizard.guice.test.jupiter.ext.conf.ExtensionBuilder
apacheClient, clientFactory, config, configModifiers, configModifiers, configOverride, configOverride, configOverrideByExtension, configOverrideByExtension, configOverrides, configOverrides, debug, disableDefaultExtensions, hooks, hooks, injectOnce, reuseApplication, with
-
Constructor Details
-
Builder
Create builder.- Parameters:
app- application type
-
-
Method Details
-
config
Same asTestGuiceyApp.config().- Parameters:
configPath- configuration file path- Returns:
- builder instance for chained calls
-
setup
@SafeVarargs public final TestGuiceyAppExtension.Builder<C> setup(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
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
-
disableManagedLifecycle
By default, guicey simulatesManagedandLifeCyclelifecycle.It might be required in test to avoid starting managed objects (especially all managed in application) because important (for test) services replaced with mocks (and no need to wait for the rest of the application).
Warning: some guice reports might stop working, because they rely on application start event
- Returns:
- builder instance for chained calls
-
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
-