Package org.robolectric.annotation
Annotation Type Config
-
@Documented @Inherited @Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface Config
Configuration settings that can be used on a per-class or per-test basis.
-
-
Field Summary
Fields Modifier and Type Fields Description static int
ALL_SDKS
static Class<? extends Application>
DEFAULT_APPLICATION
static String
DEFAULT_ASSET_FOLDER
static String
DEFAULT_MANIFEST_NAME
static String
DEFAULT_PACKAGE_NAME
static String
DEFAULT_QUALIFIERS
static String
DEFAULT_RES_FOLDER
static int
DEFAULT_VALUE_INT
static String
DEFAULT_VALUE_STRING
static int
NEWEST_SDK
static String
NONE
TODO(vnayar): Create named constants for default values instead of magic numbers.static int
OLDEST_SDK
static int
TARGET_SDK
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description Class<? extends Application>
application
TheApplication
class to use in the test, this takes precedence over any application specified in the AndroidManifest.xml.String
assetDir
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureString[]
instrumentedPackages
A list of instrumented packages, in addition to those that are already instrumented.String[]
libraries
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureString
manifest
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure builds http://robolectric.org/getting-started/int
maxSdk
The maximum Android SDK level to emulate when running tests on multiple API versions.int
minSdk
The minimum Android SDK level to emulate when running tests on multiple API versions.String
packageName
Deprecated.To change your package name please override the applicationId in your build system.String
qualifiers
Qualifiers specifying device configuration for this test, such as "fr-normal-port-hdpi".String
resourceDir
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureint[]
sdk
The Android SDK level to emulate.Class<?>[]
shadows
A list of shadow classes to enable, in addition to those that are already present.
-
-
-
Field Detail
-
NONE
static final String NONE
TODO(vnayar): Create named constants for default values instead of magic numbers. Array named constants must be avoided in order to dodge a JDK 1.7 bug. error: annotation Config is missing value for the attribute <clinit> See JDK-8013485.
-
-
-
DEFAULT_VALUE_STRING
static final String DEFAULT_VALUE_STRING
-
-
-
DEFAULT_MANIFEST_NAME
static final String DEFAULT_MANIFEST_NAME
-
-
-
DEFAULT_APPLICATION
static final Class<? extends Application> DEFAULT_APPLICATION
-
-
-
DEFAULT_PACKAGE_NAME
static final String DEFAULT_PACKAGE_NAME
-
-
-
DEFAULT_QUALIFIERS
static final String DEFAULT_QUALIFIERS
-
-
-
DEFAULT_RES_FOLDER
static final String DEFAULT_RES_FOLDER
-
-
-
DEFAULT_ASSET_FOLDER
static final String DEFAULT_ASSET_FOLDER
-
-
-
manifest
@Deprecated String manifest
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure builds http://robolectric.org/getting-started/The Android manifest file to load; Robolectric will look relative to the current directory. Resources and assets will be loaded relative to the manifest.If not specified, Robolectric defaults to
AndroidManifest.xml
.If your project has no manifest or resources, use
NONE
.- Returns:
- The Android manifest file to load.
- Default:
- "--default"
-
-
-
application
Class<? extends Application> application
TheApplication
class to use in the test, this takes precedence over any application specified in the AndroidManifest.xml.- Returns:
- The
Application
class to use in the test.
- Default:
- org.robolectric.annotation.DefaultApplication.class
-
-
-
packageName
@Deprecated String packageName
Deprecated.To change your package name please override the applicationId in your build system. Changing package name here is broken as the package name will no longer match the package name encoded in the arsc resources file. If you are looking to simulate another application you can create another applications Context usingContext.createPackageContext(String, int)
. Note that you must add this package toShadowPackageManager.addPackage(android.content.pm.PackageInfo)
first.Java package name where the "R.class" file is located. This only needs to be specified if you define anapplicationId
associated withproductFlavors
or specifyapplicationIdSuffix
in your build.gradle.If not specified, Robolectric defaults to the
applicationId
.- Returns:
- The java package name for R.class.
- Default:
- ""
-
-
-
qualifiers
String qualifiers
Qualifiers specifying device configuration for this test, such as "fr-normal-port-hdpi".If the string is prefixed with '+', the qualifiers that follow are overlayed on any more broadly-scoped qualifiers.
- Returns:
- Qualifiers used for device configuration and resource resolution.
- See Also:
- Device Configuration for details.
- Default:
- ""
-
-
-
resourceDir
@Deprecated String resourceDir
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureThe directory from which to load resources. This should be relative to the directory containing AndroidManifest.xml.If not specified, Robolectric defaults to
res
.- Returns:
- Android resource directory.
- Default:
- "res"
-
-
-
assetDir
@Deprecated String assetDir
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureThe directory from which to load assets. This should be relative to the directory containing AndroidManifest.xml.If not specified, Robolectric defaults to
assets
.- Returns:
- Android asset directory.
- Default:
- "assets"
-
-
-
shadows
Class<?>[] shadows
A list of shadow classes to enable, in addition to those that are already present.- Returns:
- A list of additional shadow classes to enable.
- Default:
- {}
-
-
-
instrumentedPackages
String[] instrumentedPackages
A list of instrumented packages, in addition to those that are already instrumented.- Returns:
- A list of additional instrumented packages.
- Default:
- {}
-
-
-
libraries
@Deprecated String[] libraries
Deprecated.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureA list of folders containing Android Libraries on which this project depends.- Returns:
- A list of Android Libraries.
- Default:
- {}
-
-