Bot releases are visible (Hide)
Published by xian almost 6 years ago
Robolectric 4.0.1 fixes several bugs in 4.0:
PackageParser
in binary resources mode [issue #4026].Activity.getLifecycle().getCurrentState()==CREATED
although activity is resumed [issue #4038].WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.
Use Robolectric:
testCompile "org.robolectric:robolectric:4.0.1"
Getting Started | Migrating | Report Issues. Enjoy!
Published by xian almost 6 years ago
Robolectric 4.0 brings support for the Android P (SDK 28) release, new and improved support and testing APIs for dozens of Android classes, initial support for some androidx-test
APIs, and a complete rewrite of the resource handling code making it behave much more like a real Android device.
With the major version number bump to 4.0, we're making changes to some public APIs, detailed below. Check out the migration notes and use the new automated migration tool to help convert your existing tests to be compatible with Robolectric 4.0.
@Implementation
methods in shadow classes are now protected
instead of public
. Tests should always prefer to call SDK methods directly on Android classes rather than on their shadows [issue #4007].RuntimeEnvironment.application
has been deprecated, use androidx.test.core.app.ApplicationProvider.getApplicationContext()
instead.AutoCloseable
is now supported. In earlier versions of Robolectric, try-with-resources blocks would fail to call close()
on the resource.In conjunction with Android Studio 3.2, Robolectric can now use resources processed using the Android build toolchain, and loads and handles those resources using the same logic as on an actual Android device. Robolectric’s old idiosyncratic resource handling mode is still available for projects not yet using the latest version of the build toolchain, but is now deprecated.
ActivityManager.getAppTasks()
ApplicationPackageManager
content providers, canRequestPackageInstalls()
AppOpsManager
AsyncQueryHandler
AudioManager.getActivePlaybackConfiguration()
BackupManager
BluetoothAdapter
profile connection state and bond stateBuild.getSerial()
CameraManager
and CameraCharacteristics
Camera.Parameters
preview sizesCarrierConfigManager.getConfigForSubId()
ConnectivityManager
support for NetworkCapabilities
, requestNetwork()
.ContentResolver.openOutputStream()
, 'getSyncAdapterTypes()'Context.bindServiceAsUser()
DevicePolicyManager.setUserProvisioningState()
EuiccManager
FontFamily
AccessibilityNodeInfo
NotificationManager
support for AutomaticZenRule
sPackageManager.checkPermission()
checks PackageInfo.requestedPermissionsFlags
to determine if a permission is granted.Path
, PathMeasure
, and PathParser
SensorManager
Service.stopSelfResult()
ShadowSensor.newInstance()
Sms
SoundPool
now records more details when play()
is called.StorageManager
test API for adding volumes.SubscriptionManager.getActiveSubscriptionInfoForSimSlotIndex()
, getActiveSubscriptionInfoCount()
etc., 'getDefaultSubscriptionId()'SystemClock.elapsedRealtimeNanos()
and currentNetworkTimeMillis()
TelecomManager.silenceRinger()
TelephonyManager.getSubscriberId()
, getSimSerialNumber()
, 'getVoiceNetworkType()'TextToSpeech
Tile
and TileService
minimal implementationTimeZoneFinder
UsbManager
UserManager
now supports multiple users.UserStatsManager
test API: ShadowUserStatsManager.simulateTimeChange()
; use EventBuilder
can be used to return arbitrary eventsVMRuntime.is64Bit()
, ShadowVMRuntime.setIs64Bit()
, ShadowBuild.setSupported64BitAbis()
WebStorage
WebView.saveState()
and restoreState()
WifiManager.connect(int, ActionListener)
RoboCursor.getLong()
.Looper.myLooper()
@Config(qualifiers)
.ShadowMediaBrowserCompat
. Also added easy ways to create MediaItem
s and get all created MediaItem
s with their parent-child relationships [thanks Jehron Petty and Noah Luddy!].
getRoot()
, getItem()
, subscribe()
, and search()
can only be called successfully after ShadowMediaBroswserCompat.connect()
is called.root_id
. This is what will be returned by getRoot()
by default. The root id can be changed with setRootId()
. Note that if the root is created with createMediaItem()
, setRootId()
must also be called with the same mediaId
.getSessionToken()
method in ShadowMediaBrowserCompat
. Follow issue #3962 for updates.@Implementation
methods against SDKs [Issue #3952]androidx.test
's ActivityScenario
API.ShadowBitmap.(set|is)Premultiplied()
and ShadowWebView.copyBackForwardList()
ActivityScenario
support [Issue #4022]View.post()
and postDelayed()
. now more properly return true
, which fixes a bug that sometimes caused duplicate tap events to be delivered.ShadowApplication.getInstance()
ShadowLooper.getShadowMainLooper()
Config(packageName)
ShadowContentResolver.clearContentObservers()
ShadowAlertDialog.getShadowAlertController()
with getAlertController()
RobolectricTestRunner
methodsShadowAccountManager.get()
ShadowKeyguardManager.setinRestrictedInputMode()
ShadowNetworkInfo.newInstance()
ShadowGradientDrawable.getColor()
with getLastSetColor()
WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.
Use Robolectric:
testCompile "org.robolectric:robolectric:4.0"
Find more details here. Report issues here. Enjoy!
Published by xian almost 6 years ago
NOTE: Robolectric 4.0-beta-3 is a outdated release candidate; please use 4.0 instead.
Published by brettchabot almost 6 years ago
NOTE: Robolectric 4.0-beta-2 is a outdated release candidate; please use 4.0 instead.
Published by xian about 6 years ago
NOTE: Robolectric 4.0-beta-1 is a outdated release candidate; please use 4.0 instead.
Published by brettchabot about 6 years ago
NOTE: Robolectric 4.0-alpha-3 is a outdated release candidate; please use 4.0 instead.
Published by brettchabot over 6 years ago
NOTE: Robolectric 4.0-alpha-2 is a outdated release candidate; please use 4.0 instead.
Published by xian over 6 years ago
NOTE: Robolectric 4.0-alpha-2 is a outdated release candidate; please use 4.0 instead.
Published by brettchabot over 6 years ago
Robolectric 3.8 brings support for Android P, performance improvements, and numerous other fixes and improvements.
ActivityController.windowFocusChanged()
API.NotificationManager
simulation improvements [issue #3617].ActivityManager.getMyMemoryState
[issue #3775].isStopped()
method to ShadowTextToSpeech
[issue #3818].setManifestShortcuts()
and setMaxShortcutCountPerActivity()
to ShadowShortcutManager
[issue #3803].Settings#canDrawOverlays()
.ShadowNetworkInfo#newInstance()
and setConnectionStatus()
.ShadowMediaPlayer
does not correctly handle instantiation off the UI thread. [issue #3050].MessageQueue
/Looper
and ViewRootImpl
.JarInstrumentor
to sandbox module [issue #3806].Use Robolectric:
testCompile "org.robolectric:robolectric:3.8"
Find more details here. Report issues here. Enjoy!
Published by brettchabot over 6 years ago
Robolectric 3.7.1 contains two regression fixes.
com.android.support.test:monitor:1.0.2-alpha1
. If your project already depends on com.android.support.test.*
, you should upgrade to 1.0.2-alpha1 to avoid potential conflicts e.g. java.lang.VerifyError: class org.robolectric.android.fakes.RoboMonitoringInstrumentation overrides final method specifyDexMakerCacheProperty
.Use Robolectric:
testCompile "org.robolectric:robolectric:3.7.1"
Find more details here. Report issues here. Enjoy!
Published by jongerrish over 6 years ago
Robolectric 3.7 brings simulation improvements and better shadow support as well as numerous other fixes and improvements.
This is the second of several releases in which we're replacing Robolectric's hacked-together approximations of the Android resource management code with actual code from the framework. The result should be a vastly more correct Android simulation.
FingerprintManager
, KeyguardManager
, SearchManager
, ShortcutManager
, UsbManager
, RestrictionsManager
, TextClassificationManager
, and AutofillManager
.PackageManager
, using much more actual Android framework code for manifest parsing.UserManager
, WifiManager
, TelephonyManager
, and DevicePolicyManager
.@Implementation
methods can and should now be protected.ActivityTestRule
and Espresso Intents.com.android.support.test:monitor:1.0.2-alpha1
. If your project already depends on com.android.support.test.*
, you should upgrade to 1.0.2-alpha1 to avoid potential conflicts e.g. java.lang.VerifyError: class org.robolectric.android.fakes.RoboMonitoringInstrumentation overrides final method specifyDexMakerCacheProperty
.public
to protected
. Your test code may have been calling these erroneously instead of calling the Android SDK method, e.g: preferPackageManager.getPackageInfo()
to ShadowPackageManager.getPackageInfo()
. This is easily fixed by calling the SDK method instead.AndroidManifest
has been removed; instead, use PackageManager
APIs.ShadowApplication.getReceiversForIntent()
and hasReceiversForIntent()
are deprecated; use PackageManager
APIs instead.ShadowUserManager.setSerlialNumberForUser()
is deprecated; use addUserProfile()
instead.@Implementation(inheritImplementationMethods = true)
is largely unnecessary and will be removed in a forthcoming release.equals/hashcode/toString
support in cases where the method exists only on a parent of the shadowed class is deprecated. Don't shadow equals()
for the purposes of testing or assertions, rather only for simulation equivalency.RoboLayoutInflater
is deprecated; use LayoutInflater
instead.RoboVibrator
is deprecated, functionality has moved to ShadowVibrator
.FingerprintManager
[issue #3266—thanks @andreszamoraglobant].ShadowMatrix
does not implement map* methods [issue #3602—thanks @Kalabasa].WifiManager
throws NPE [issue #3655—thanks @qsjh898].ShadowAccessibilityNodeInfo.equals()
test to use a unique source ID
[issue #3623].@Implementation
methods to be protected instead of public [issue #3130].ManifestIdentifier.create()
[issue #3634].minSdkVersion
should be Jelly Bean (16), not 1 [issue #3650].ManifestFactory.create()
[issue #3636].@Config
[issue #3667].ShadowPackageManager#setQueryIntentImplicitly
[issue #3672].ATSL
support as an optional dependency [issue #3679].getFromLocation
on ShadowGeocoder
[issue #3678—thanks @josecoelho].@Implementation
method resolution [issue #3705].RGBA_F16
to getBytesPerPixel
in ShadowBitmap
[issue #3687].Parcel.readByteArray()
[issue #3710—thanks @cesar1000].ShadowMatrix
mapPoints
and mapVectors
[issue #3609—thanks @Kalabasa].AndroidManifest
from shadows [issue #3682].UserManager
simulation improvements [issue #3681].PackageManager
[issue #3680].ShadowActivityThreadTest
[issue #3717].ConfigMerger
to be overridden [issue #3713].ShadowTelephonyManager.setIsSmsCapable
[issue #3702].FingerprintManager
[issue #3696].ConnectivityManager.OnNetworkActiveLi
… [issue #3694].RoboInstrumentation
and code cleanup [issue #3690].android.net.INetworkPolicyManager
to ServiceManager
[issue #3689].InstrumentationRegistryTest
when running on device [issue #3686].ActivityTestRule
support [issue #3685].KeyguardManager
simulation improvements [issue #3644].UserManager
simulation enhancements [issue #3643].UserManager.getApplicationRestrictions()
[issue #3637].DevicePolicyManager
simulation enhancements [issue #3675].JDK
version, Robolectric requires Java 8 anyway [issue #3669].activityInfo.exported
and permission and add ShadowPackageManager.getIntentFiltersForXXX
APIs [issue #3666].UserManager
simulation enhancements [issue #3662].RestrictionsMananger
support getManifestRestrictions()
[issue #3660].KeyguardManager
simulation improvements [issue #3658].RestrictionsManager
[issue #3656].ProxyMaker
to use reflection to run on ART API < 26 [issue #3649].UserManager
simulation enhancements [issue #3648].ShadowsAdapter
APIs [issue #3627].@Deprecated
TestLifeCycle.createApplication()
[issue #3624].Robolectric.getShadowsAdapter()
[issue #3622].KeyguardManager
's isKeyguardSecure()
is API 16 [issue #3631].RuntimeEnvironment.getAppManifest
[issue #3628].SQLiteDatabaseTest
[issue #3444].InstrumentingClassLoader.getCommonSuperClass()
[issue #3726].WORKSPACE
file and fix path [issue #3735—thanks @dkelmer].WifiManager
simulation enhancements [issue #3727].@Implementation
methods protected [issue #3724].NPE
when dereferencing [issue #3739].ShadowCanvas
[issue #3521—thanks @cesar1000].ATSL
Intents verification API on Robolectric [issue #3728].RobolayoutInflator
with PhoneLayoutInflator
as per framework [issue #3741].ShadowPorterDuffColorFilter
[issue #3522—thanks @cesar1000].ShadowToast
to check whether a toast was cancelled [issue #3711—thanks @cesar1000].SharedPreferences
will not persist edits across getSharedPreferences
calls [issue #3510—thanks @setheclark].SharedPreferences
' commit() hangs if executed after apply() on Android O [issue #3641—thanks @kzaikin].BadParcelableException
when unmarshalling Parcelable extending class [issue #2398—thanks @menny].WARNINGs
[issue #3646—thanks @XinyueZ].Use Robolectric:
testCompile "org.robolectric:robolectric:3.7"
Find more details here. Report issues here. Enjoy!
Published by xian almost 7 years ago
Robolectric 3.6.1 fixes a couple small issues in 3.6.
android.support.test
's InstrumentationRegistry
and ActivityTestRule
for now, didn't work with Android Gradle Plugin 2.x [issue #3614].Use Robolectric:
testCompile "org.robolectric:robolectric:3.6.1"
Find more details here. Report issues here. Enjoy!
Published by xian almost 7 years ago
Robolectric 3.6 provides enhanced device configuration, fixes lots of idiosyncrasies in how resources were picked based on device configuration, and includes numerous other fixes and improvements.
This is the first of several releases in which we're replacing Robolectric's hacked-together approximations of the Android resource management code with actual code from the framework. The result should be a vastly more correct Android simulation.
@Config(qualifiers="...")
are used to configure the virtual device's simulated locale, display, and hardware for the test.Display
and DisplayMetrics
now match the device's configuration.ShadowDeviceManager#addDisplay()
et al.Build
constants and ActivityManager.isLowRamDevice
[issue #3576].android.support.test
's InstrumentationRegistry
and ActivityTestRule
[issue #3568 and #3578].SmsManager
[issue #3561].ConnectivityManager
to bind networks [issue #3539].ContextImpl.getSystemService(Context.CAPTIONING_SERVICE)
[issue #3527].PackageManager.queryIntentServicesAsUser()
[issue #3597].ICU
[issue #3553].AppOpsManager
and CaptioningManager
[issues #3494 and #3527].context.startForegroundService()
[issue #3517].anydpi
and nodpi
may no longer be specified as @Config(qualifiers)
. SDKs which are able to render vector drawables will match anydpi
drawables.ContentObserver
s now respect notifyForDescendents
[issue #3544].AssetManager.open()
and list()
now include assets from libraries [issue #3605].AlarmClockInfo
to AlarmManager
[issue #3483].PackageManager
now handles the MATCH_DISABLED_COMPONENTS
flag [issue #3499].Log.getLogsForTag()
returns empty list instead of null
if no logs with that tag are present [issue #3550].ActivityController
lifecycle handling [issue #3591].AccountManageFuture.isDone()
no longer returns true on failure [issue #3603].AccessibilityNodeInfo
child comparing children [issues #3589 and #3579].PackageManager.getResolveInfo()
[issue #3513].PendingIntent
[issue #3465].TestLifecycle.createApplication()
[issue #3555].ShadowPackageManager.setQueryIntentImplicitly()
[issue #3584].ShadowsAdapter
and Robolectric.getShadowsAdapter()`: access shadows directly instead.Qualifiers
: use @Config(qualifiers)
and related Android platform APIs instead.Display
: eg. ShadowApplication.setDefaultDisplay()
, ShadowDisplay.setDisplayId()
: use @Config(qualifiers)
or RuntimeEnvironment.setQualifiers()
instead.Use Robolectric:
testCompile "org.robolectric:robolectric:3.6"
Find more details here. Report issues here. Enjoy!
Published by xian almost 7 years ago
NOTE: Robolectric 3.6-alpha-1 is a outdated release candidate; please use 3.6 instead.
Published by xian almost 7 years ago
Robolectric 3.5.1 provides support for Android O_MR1 8.1 beta and two regression fixes.
IllegalStateException
[issue #3478].Use Robolectric:
testCompile "org.robolectric:robolectric:3.5.1"
Find more details here. Report issues here. Enjoy!
Published by xian almost 7 years ago
Robolectric 3.5 provides support for Android O 8.0.0_r4 and includes numerous fixes and improvements.
DevicePolicyManager
[issue #3325] and UsbManager
[issue #3420].Filterable
filtering are now correctly caught [issue #3331].AlarmManager
and PendingIntent
s [issue #3332].WebView
handles history more consistently [issue #3347].BroadcastReceiverData
and ServiceData
from the manifest [issue #3361].ApplicationPackageManager.getPackageUid()
[issue #3370].ContentResolver.getPersistedUriPermissions()
[issue #3400].PowerManager.isIgnoringBatteryOptimizations()
[issue #3399].KeyguardManager#isKeyguardLocked()
[issue #3401].UserManager.getSerialNumberForUser()
[issue #3406].NotificationManager.deleteNotificationChannelGroup()
[issue #3334] and createNotificationChannels()
[issue #3340].ApplicationInfo.uid
and Process.myUid()
[issue #3440].TextUtils.ellipsize()
[issue #3442].KeyguardManager
on O [issue #3454].Activity.finishAffinity()
correctly causes an activity to be marked finished [issue #3460].AsyncTask
[issue #3321].AccessibilityManager
now retains state correctly [issue #3372].res
directory no longer cause an exception [issue #3398].ManifestFactory.create()
, RuntimeEnvironment.getAppManifest()
, and ShadowApplication.getAppManifest()
[issue #3447]. AndroidManifest
itself will be deprecated soon; use PackageManager
instead.WebView.setCanGoBack()
.org.robolectric.util.SimpleFuture
[issue #3321].shadows-framework
, etc. Sorry for the thrash on this.@Implementation
(issue #3122).Use Robolectric:
testCompile "org.robolectric:robolectric:3.5"
Find more details here. Report issues here. Enjoy!
Published by hoisie about 7 years ago
Robolectric 3.4.2 updates the supported version of Android O to Developer Preview 4.
Published by xian about 7 years ago
NOTE: this release has a minor bug and has been superseded by 3.4.2.
Published by xian about 7 years ago
Robolectric 3.4 improves support for Android O Developer Preview 2, PackageManager
, and many other Android classes, and resolves numerous bugs.
NotificationManager
features added in Android O [issue #3041].BatteryManager
[issue #3006].UserManager
user restrictions [issue #3027].PowerManager.newWakeLock()
[issue 3078].BackupAgentController
test API for backup agents [issue #3016].BuildCompat
's version checking methods; Build.VERSION.CODENAME
is now correctly initialized [issue #3031].ContentResolver
.Configuration.orientation
now matches the orientation indicated by @Config(qualifiers)
[issue #3046].SharedPreferences
uses real Android SDK code rather than a shadow [issue #3051].Robolectric.setupContentProvider()
can now be called with an authority string [issue #3019].ContentProvider
s [issue #3022].SensorManager.createDirectChannel()
.get{Target|Creator}Package()
to ShadowPendingIntent
[issue #3033].PackageManager.getResourcesForApplication()
[issue #3133].PackageManager.queryPermissionsByGroup()
[issue #3160].PackageManager.getApplicationInfo()
[issue #3160].PackageManager.getProviderInfo()
[issue #3191].ShadowInputMethodManager
now supports a callback mechanism for soft input visibility changes [Issue #3136].StatFs
[issue #3128].WifiManager.getPrivilegedConfiguredNetworks()
[issue #3134].WifiManager#getWifiState()
[issue #3146].WifiManager#isScanAlwaysAvailable()
[issue #3259].queryIntentService()
from Manifest [issue #3153].UserManager.isManagedProfile()
[issue #3154].PackageInfo.name
value to ActivityInfo
[issue #3159].DownloadManager
[issue #3163].Session.abandon()
[issue #3189].JobScheduler.getPendingJob(int)
introduced in Android N [issue #3195].TempDirectory
shared across entire test env [issue #3199].AudioManager
and TelephonyManager
[issue #3255].ShadowService.foregroundStopped
is now reset when a service goes into the foreground [issue #3261].ShadowChoreographer
now allows customized delay to be specified by application for postCallback
and postFrameCallback
to avoid animation problems during test [issue #3262].listen()
behavior to ShadowTelephonyManager
[issue #3271].ShadowLog.getLogs()
and getLogsForTags()
[issue #3007].targetSdkVersion
of O
[issue #3037].Resources.openRawResource()
to throw the wrong exception for missing resources [issue #3059].ContentResolver
[issue #3067].Looper
tasks to leak between tests [issue #2963].MessageQueue
to block adding messages to the queue while a message was being handled [issue #3082].ShadowSensorManager
and ShadowNotificationManager
to be compatible with older SDK versions [issue #3103, #3101].ActivityManager.getRunningAppProcesses()
to return an empty list instead of null [issue #3124].BluetoothDevice
objects from being created [issue #3197].WifiConfiguration.toString()
[issue #3144].Choreographer
constructor for O [issue #3240].ShadowSQLiteConnection.reset
[issue #3211].res
[issue #3158].DefaultPackageManager
and RobolectricPackageManager
[issues #3203 and #3264].org.robolectric.util
controllers [issue #3087].ShadowConfiguration
[issue #3094].Transcript
[issue #3113].*LayoutParams
Shadows [issue #3118].StubPackageManager
[issue #3151].*CursorAdapter
Shadows [issue #3117].ComponentController.attach()
method [issue #3185].org.robolectric.res.builder.XmlResourceParserImpl
.build.gradle
files will need to updated accordingly. [issue #3186]:
robolectric-annotations
-> annotations
robolectric-junit
-> junit
robolectric-processor
-> processor
robolectric-resources
-> resources
robolectric-sandbox
-> sandbox
robolectric-utils
-> utils
shadows-core
-> framework
shadows-httpclient
-> httpclient
shadows-maps
-> maps
shadows-multidex
-> multidex
shadows-play-services
-> playservices
shadows-support-v4
-> supportv4
@Config
attributes that are supplied via new build system API [issue #3230].RuntimeAdapter
[issue #3218].ShadowExtractor
, AccessibilityUtil
, and RoboExecutorService
[issue #3174].Use Robolectric:
testCompile "org.robolectric:robolectric:3.4"
Find more details here. Report issues here. Migration notes here. Enjoy!
Published by xian about 7 years ago
NOTE: Robolectric 3.4-rc4 is a outdated release candidate; please use 3.4-rc5 instead.