T
- the configuration object’s typepublic interface Configurer<T>
Provides configuration data for tests.
The test author can apply configuration data at a package, class, or method level, or any combination of those. See Configuring Robolectric for more details.
The implementation of the configurer determines how config information is collected and merged for each test.
For a test:
class com.foo.MyTest extends com.foo.BaseTest {
@Test void testMethod() {}
}
the configuration is applied in the following order:
defaultConfig()
.Configuration objects can be accessed by shadows or tests via org.robolectric.config.ConfigRegistry.get(Class)
.
Modifier and Type | Method and Description |
---|---|
T |
defaultConfig()
Returns the default configuration for tests that do not specify a configuration of this type.
|
Class<T> |
getConfigClass()
Retrieve the class type for this Configurer
|
T |
getConfigFor(Class<?> testClass)
Returns the configuration for the given class.
|
T |
getConfigFor(Method method)
Returns the configuration for the given method.
|
T |
getConfigFor(String packageName)
Returns the configuration for a given package.
|
T |
merge(T parentConfig,
T childConfig)
Merges two configurations.
|
@Nonnull T defaultConfig()
Returns the default configuration for tests that do not specify a configuration of this type.
T getConfigFor(@Nonnull String packageName)
Returns the configuration for a given package.
This method will be called once for package in the hierarchy leading to the test class being configured. For example, for com.example.FooTest
, this method will be called three times with "com.example"
, "com"
, and ""
(representing the top level package).
packageName
- the name of the package, or the empty string representing the top level unnamed packagenull
if the given properties has no relevant data for this configurationT getConfigFor(@Nonnull Class<?> testClass)
Returns the configuration for the given class.
This method will be called for each class in the test’s class inheritance hierarchy.
null
if the given class has no relevant data for this configurationT getConfigFor(@Nonnull Method method)
Returns the configuration for the given method.
null
if the given method has no relevant data for this configuration@Nonnull T merge(@Nonnull T parentConfig, @Nonnull T childConfig)
Merges two configurations.
This method will called whenever getConfigFor(java.lang.String)
returns a non-null configuration object.
parentConfig
- a less specific configuration objectchildConfig
- a more specific configuration object