Package org.robolectric.annotation
Annotation Type Implements
Indicates that a class declaration is intended to shadow an Android class declaration. The
Robolectric runtime searches classes with this annotation for methods with the
Implementation
annotation and calls them in place of the methods on the Android class.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An interface used as the default for thepicker
param. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionboolean
If set to true, Robolectric will invoke the native method variant instead of the no-op variant.boolean
If true, Robolectric will invoke the actual Android code for any method that isn't shadowed.Android class name (if the Class object is not accessible).boolean
Denotes that this type exists in the public Android SDK.boolean
Deprecated.int
If specified, the shadow class will be applied only for this SDK or lesser.int
If specified, the shadow class will be applied only for this SDK or greater.Class<? extends ShadowPicker<?>>
If specified, thepicker
will be instantiated and called from within the newly-created Robolectric classloader.Class<?>
The Android class to be shadowed.
-
Element Details
-
value
Class<?> valueThe Android class to be shadowed.- Returns:
- Android class to shadow.
- Default:
- void.class
-
className
String classNameAndroid class name (if the Class object is not accessible).- Returns:
- Android class name.
- Default:
- ""
-
isInAndroidSdk
boolean isInAndroidSdkDenotes that this type exists in the public Android SDK. When this value is true, the annotation processor will generate a shadowOf method.- Returns:
- True if the type is exposed in the Android SDK.
- Default:
- true
-
callThroughByDefault
boolean callThroughByDefaultIf true, Robolectric will invoke the actual Android code for any method that isn't shadowed.- Returns:
- True to invoke the underlying method.
- Default:
- true
-
looseSignatures
Deprecated.Use theClassName
annotation or theImplementation.methodName()
annotation parameter instead.If true, when an exact method signature match isn't found, Robolectric will look for a method with the same name but with all argument types replaced with java.lang.Object.- Returns:
- True to disable strict signature matching.
- Default:
- false
-
minSdk
int minSdkIf specified, the shadow class will be applied only for this SDK or greater.- Default:
- -1
-
maxSdk
int maxSdkIf specified, the shadow class will be applied only for this SDK or lesser.- Default:
- -1
-
shadowPicker
Class<? extends ShadowPicker<?>> shadowPickerIf specified, thepicker
will be instantiated and called from within the newly-created Robolectric classloader. All shadow classes implementing the same Android class must use the sameShadowPicker
.- Default:
- org.robolectric.annotation.Implements.DefaultShadowPicker.class
-
callNativeMethodsByDefault
boolean callNativeMethodsByDefaultIf set to true, Robolectric will invoke the native method variant instead of the no-op variant. This requires the native method to be bound, or anUnsatisfiedLinkError
will occur.This method has precedence over
callThroughByDefault()
. For instance, if both this method andcallThroughByDefault()
are true, the native method variant will be preferred over the no-op native variant.- Default:
- false
-
ClassName
annotation or theImplementation.methodName()
annotation parameter instead.