Robolectric has many components which can be customized or replaced using an extension
mechanism based on Java Services
.
Historically, customizing Robolectric required subclassing RobolectricTestRunner
to override behavior at various ad-hoc extension points.
This mechanism is now deprecated. The Plugin API provides a number of well documented and
supported extension points allowing you to customize behavior for your organization's needs.
The interfaces listed below can be implemented with customizations suitable for your organization. To make your custom implementation visible to Robolectric, publish it as a service and include it in the test classpath.
Extension points:
ConfigurationStrategy
(default HierarchicalConfigurationStrategy
)
DependencyResolver
(default LegacyDependencyResolver
GlobalConfigProvider
(no default)
PerfStatsReporter
(no default)
SdkPicker
(default DefaultSdkPicker
)
SdkProvider
(default DefaultSdkProvider
)
Interface | Description |
---|---|
SdkPicker | |
SdkProvider |
A provider of known instances of
Sdk . |
TestEnvironmentLifecyclePlugin |
Plugin which allows behaviour extension in TestEnvironment.
|
UsesSdk |
Represents the contents of a
uses-sdk element in an Android manifest file. |
Class | Description |
---|---|
Sdk |
Represents a unique build of the Android SDK.
|
Annotation Type | Description |
---|---|
ExtensionPoint |
Marks a component of Robolectric that may be replaced with a custom implementation.
|