Skip to content

Releases: robolectric/robolectric

Robolectric 4.4 Alpha 2

23 Jul 06:06
Compare
Choose a tag to compare
Pre-release

NOTE: Robolectric 4.4-alpha-2 is a outdated preview release; please use 4.4 or later instead.

Robolectric 4.4 Alpha 1

08 Jul 16:17
Compare
Choose a tag to compare
Pre-release

NOTE: Robolectric 4.4-alpha-1 is a outdated preview release; please use 4.4 or later instead.

Robolectric 4.3.1

14 Oct 16:57
Compare
Choose a tag to compare

Robolectric 4.3.1 adds support for Android API 29 (Q final).

Compatibility

  • Running tests on Android API 29 now strictly requires a Java9 runtime or newer. If you are seeing errors about unsupported Java version when running tests on API 29 via Android Studio; you can use the 'JRE' field in the Run Configuration dialog to configure a newer Java runtime. See https://developer.android.com/studio/run/rundebugconfig for more background.

Robolectric 4.3

30 May 17:48
Compare
Choose a tag to compare

This release introduces a new PAUSED Looper mode, enhanced Espresso compatibility, support for Android Q Beta 2, and numerous SDK support improvements and bug fixes

Features

  • Support Android Q beta 2 (build 5415296). [1717fb1]
  • Support for new PAUSED Looper mode.
  • Support clicking menu items via Espresso [issue #4889]
  • More realistically measure and layout Android text views

Android SDK support and Test API changes

  • Use real OverScroller in PAUSED LooperMode. [4337639]
  • Add ShadowDevicePolicyManager#isLockTaskPermitted(String).
  • Add Locale methods to Shadow for CaptioningManager.
  • Add enabling/disabling data in ShadowTelephonyManager. [issue #4844]
  • Add an initial shadow for the LauncherApps System Service. [issue #4837]
  • Add ShadowUserManager.removeUser(UserHandle) [issue #4854]
  • Add IntentSenderRequest for startIntentSenderForResult methods. [issue #4870]
  • Shadow night display ColorDisplayManager methods
  • Add getPasswordComplexity support to ShadowDevicePolicyManager [issue #4878]
  • Add shadow implementation for ShadowDexFile.isDexOptNeeded. [issue #4886]
  • Shadow DisplayManagerGlobal#getStableDisplaySize [issue #4838]
  • Shadow ContextImpl.startActivityAsUser [issue #4899]
  • Shadow implementation of android.hardware.HardwareBuffer [issue #4895]
  • Add shadow for ShadowAppOpsManager#noteProxyOpNoThrow. [issue #4906]
  • Add support for new Android Q fields to EventBuilder [issue #4905]
  • Add support for UsageStatsManager#getUsageSource() [issue #4920]
  • Support stopForeground(int) in ShadowService. [issue #4919]
  • Support ShadowSensor#getMaximumRange [issue #4881]
  • Add support for passing resultCode through to broadcasts intents [issue #4917]
  • Fix activities leaking between test cases [issue #4930]
  • Fall back to Android's implementation of PackageManager.getPackageArchiveInfo [issue #4928]
  • Add ShadowPausedAsyncTask#overrideExecutor API to replace waitForIdle. [issue #4950]
  • Add API ShadowApplicationPackageManager.getLeanbackLaunchIntentForPackage() (wraps getLaunchIntentForPackage()) [c16c3bf]
  • Add new shadow Looper APIs for retrieving the scheduled time for tasks. [6494bde]
  • Added Robolectric shadow for TotalCaptureResult. [8e1e585]
  • Add ShadowLooper#isIdle [f4a5d49]
  • Create APIs for executing tasks on real background threads in PAUSED looper mode. [d29bf89]
  • Add get/setLockTaskPackages support to DevicePolicyManager [b1ecc5a]
  • Add implementation of - ShadowSubscriptionManager#getAvailableSubscriptionInfoList - ShadowSubscriptionManager#setAvailableSubscriptionInfoList - ShadowSubscriptionManager#setAvailableSubscriptionInfos - SubscriptionInfoBuilder#setMnc [95bac4a]
  • Modify ShadowLocationManager to respect LOCATION_MODE. [348d0d2]
  • Make ActivityController#recreate aware of the current lifecycle state [7cc5b42]
  • Implement ActivityManager#isBackgroundRestricted() [4cbe349]
  • UiModeManager [78a4eec]
  • Set different values for each of OsConstants errno values [aeadc29]
  • Add ShadowIsoDep [2e94093]
  • Add ShadowBluetoothGatt.connect() [8cffa29]
  • Implement SubscriptionManager.getPhoneId() with a map between subscription IDs and phone IDs. [01ea680]
  • Add torch setting capabilities to ShadowCameraManager. [f25ec77]
  • Add method to ShadowContextWrapper to expose the options of the most recently started activity [da1bace]
  • Add setInMultiWindowMode() to change multi window state for ShadowActivity. [9b2af0b]
  • Supports setProfileClass & setIsEmbedded in SubscriptionInfoBuilder [4c74611]
  • Supports EuiccManager#getEid in ShadowEuiccManager [e64f675]
  • Fake out a minimal implementation of ShadowSliceManager.getPinnedSlices(). [2f7aa83]
  • Add setSeedAccountType() for ShadowUserManager [70d712f]
  • Allow delivering broadcasts by class name. [665000d]
  • Add shadow for ColorDisplayManager per-app grayscale [095c527]
  • Add ShadowApplication#clearRegisteredReceivers helper method [c0d1719]
  • Enhance ShadowBroadcastReceiver to allow testing async receivers [78c3998]
  • Add supportsMultipleUsers() & setSupportsMultipleUsers() for ShadowUserManager [50ec6ed]
  • Support tag in ShadowWakeLock [3137c1c]
  • Add createConfirmFactoryResetCredentialIntent to ShadowKeyguardManager [1d20033]
  • ShadowInputDevice: Add shadow implementation for the getProductId() and getVendorId() methods. [8aa09a5]
  • Add switchUser(UserHandle) for ShadowActivityManager [7a63796]
  • Creating a Shadow for NetworkCapabilities. The current implementation only overrides fetching and updation of transport. [d432dcf]
  • Allow ShadowEvent to set thread id as well. [ff84723]
  • Add partial (backward) @Implementation of goBackOrForward(steps) to ShadowWebView [a616926]
  • Create a Shadow for SigningInfo, which was added in API 28. [dd1d408]
  • Implement ShadowBinder.setCallingUserHandle() / Binder.getCallingUserHandle() [aaa393b]
  • Support ShadowBluetoothDevice.connectGatt() overloads. [7d95ef4]
  • Implement AccountManager.removeAccount(...) with Activity parameter. [63816d7]
  • Fix ShadowMediaPlayer.setDataSource(MediaDataSource) [c3037c1]
  • add missing shadow of MediaPlayer.setDataSource(MediaDataSource) [2876f57]
  • Add getDefault{X}SubscriptionId() equivalents for older versions of Android to ShadowSubscriptionManager. [daa72ae]

Configuration

  • Introduced an opt-in mode that fixes zero-sized TextViews in Robolectric [9bfa258]
  • Move ConfigurationRegistry into shadowsapi [b5e63df]
  • Added extension points to AndroidEnvironment and ClassInstrumentor [3604e42]

Bug Fixes

  • Fix another 'NoSuchMethodError java.nio.ByteBuffer.position' issue in Java8 [804b89a]
  • Fix concurrent modification exception in ShadowAlarmManager [03fd8c3]
  • Fixed transliteration problems where cpp copy assignments were transliterated as java reference copies
  • Propagate RemoteException from Binder#onTransact method
  • Fix AccessibilityNodeinfo.obtation(NodeInfo) to clone Extra correctly [issue #4865]
  • Protecting ShadowSensorManager.sendSensorEvent from ConcurrentModificationException [issue #4839]
  • Synchronize cleanup of ApkAssets cache with corresponding native object [issue #4910]
  • Fix a bug causing flakes when using ShadowSQLiteConnection. [issue #4904]
  • Fix typing text into phone EditText fields. [issue #4909]
  • Includes st_mode in Os.stat/lstat/fstat system calls. [issue #4915]
  • Fixed an issue where nine patch chunks are overridden [issue #4914]
  • Ensure ActivityScenario lifecycle events are consistent with device. [issue #4954]
  • Make Instrumentation.runOnMainSync behave consistently with device. [issue #4951]
  • Make sure that ShadowAccountManager doesn't crash on empty features. [issue #4953]
  • Initialize Robolectric environment location properly. [72fa419]
  • Introduced an opt-in mode that fixes zero-sized TextViews in Robolectric [9bfa258]
  • Oops, missed a Q Beta 1 shadow. [04db5d5]
  • Don't instrument androidx.room.CoroutinesRoom$Companion. [6d24639]
  • Stem CachedDependencyResolverFileCacheTest flakiness by increasing valid cache time. [10acb64]
  • Windows actually works finally, maybe [issue #4605].
  • Fixes bug in activity lifecycle state transition with finish() in onCreate [7e0d8c1]
  • Apply fixes from LocalActivityInvoker to RoboMonitoringInstrumentation. [017559d]

Deprecations and Removals

  • @Deprecate a bunch of methods in ShadowView where alternatives exist in Espresso [312376d]

Internal Changes

  • Updated to AndroidX Test 1.2.0 [47c0736]
  • Restructure ShadowLooper and related shadows into a abstract base 'API' class, and two subclasses: ShadowLegacy* and
    ShadowPaused*. A shadowPicker will be used to pick the correct shadow to use based on LooperMode.
  • Exclude Arch Components and Room from Shadows [issue #4883]
  • Break org.robolectric:annotations -> org.robolectric:shadow-api dependency [issue #4948]
  • Rename (Android)?Environment to (Android)?TestEnvironment. [6308e4f] [issue #4850]
  • Idle main looper after each SupportFragmentTestUtil call when looper mode is PAUSED. [78d27a9]
  • Added missing native functions in ShadowRenderNode [7740562]
  • Add setExecutor shadow API [1e2c79c]
  • Introduce a new "Paused looper" threading model. [acb7af7]
  • Change ShadowNativeAllocationRegistry to use loose signatures [5409c0d]
  • Create a LooperMode configurer annotation. [8e26be1]
  • Enable callThroughByDefault for NativeAllocationRegistry, and explicitly shadow methods instead. [1f5f0fe]
  • Allow ShadowAppOpsManager#toOpEntry to be overridden, and make TestUtil use injected DependencyResolver and SdkProvider. [adad503]
  • Refactor exception-message assertions to use ThrowableSubject.hasMessageThat(). [729acc2]
  • Add link to github issue explaining workaround. [9ef6e60]
  • Attempt 2 at clearing exception handler. [2fd0a1b]
  • Merge pull request #4736 from robolectric/undeclared-activtiy-workaround [a4275f1]
  • Internal change [f662314]
  • Aggregate test results from all projects. [65b0975]
  • Ignore mysterious AGP fail: [1b0d479]
  • Test for AGP manifest bug workaround. [6d57524]
  • Make it clear that Util.sneakyThrow() disrupts program flow. [316e3f0]
  • Remove ShadowHandler - it is an empty implementation now. [bcbf11d]
  • Fix ShadowAppOpsManager.toOpEntry() compilation. [37d9948]
  • Merge pull request #4645 from robolectric:jakew/sneaky-throw/2019-02-17 [91af73f]
  • Internal change [f3980e1]
  • Fix call order of postCreate() and sta...
Read more

Robolectric 4.3 Beta1

06 May 21:34
Compare
Choose a tag to compare
Robolectric 4.3 Beta1 Pre-release
Pre-release

NOTE: Robolectric 4.3-beta-1 is a outdated preview release; please use 4.3 or later instead.

Robolectric 4.3 Alpha 3

01 May 18:14
Compare
Choose a tag to compare
Pre-release

NOTE: Robolectric 4.3-alpha-3 is a outdated preview release; please use 4.3 or later instead.

Robolectric 4.3 Alpha 2

04 Apr 23:15
Compare
Choose a tag to compare
Pre-release

NOTE: Robolectric 4.3-alpha-2 is a outdated preview release; please use 4.3 or later instead.

Robolectric 4.2.1

15 Mar 23:57
Compare
Choose a tag to compare

This release introduces a new extension mechanism for Robolectric, fixes a major performance regression in 4.x, and includes numerous SDK support improvements and bug fixes.

Bug Fixes

  • Robolectric 4.2.1 fixes a number of issues when running tests on Windows [issue 4670].
  • Applied fixes to activity lifecycle RoboMonitoringInstrumentation [4c7f968].

Known Issues

  • Activities must now be explicitly declared in a manifest (as is the case for normal Android); however, Android Gradle Plugin doesn't currently merge a test manifest. See #4736 for more context and #4727 for a workaround.
  • Android Gradle Plugin 3.2.1 and 3.3 report the following warning, which may be safely ignored: WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.. Android Gradle Plugin 3.4 will resolve this issue.
  • Android Gradle Plugin 3.2.1 does not work on Windows; use 3.3+ instead [issue #3955].

Compatibility

  • Android Studio/Android Gradle Plugin 3.3 or 3.4 Beta
  • Android SDK 28 (includes support for testing against SDKs from 16 on)

Use Robolectric:

testCompile "org.robolectric:robolectric:4.2.1"

Find more details here. Report issues here. Enjoy!

Robolectric 4.3 Alpha 1

15 Mar 22:46
Compare
Choose a tag to compare
Pre-release

NOTE: Robolectric 4.3-alpha-1 is a outdated preview release; please use 4.3-alpha-2 or later instead.

Robolectric 4.2

14 Feb 21:02
Compare
Choose a tag to compare

This release introduces a new extension mechanism for Robolectric, fixes a major performance regression in 4.x, and includes numerous SDK support improvements and bug fixes.

Features

  • Robolectric 4.2 introduces a new plugin system, replacing the previous ad-hoc customization mechanisms (subclassing RobolectricTestRunner, providing system properties, etc.). The old mechanisms are deprecated and will eventually be removed; let us know if there are missing extension points you need. See org.robolectric.pluginapi for more details [issue #4362].
  • Fixed a significant performance regression in 4.x. Thanks @cesar1000! [issues #4142, #4585].
  • For developers of custom shadows, Robolectric 4.2 has a new typesafe and more performant way to access fields and methods on @RealObjects using the Reflector API [issues #4361, #4315, #4351, #4456]

Android SDK support and Test API changes

  • Activities must now be explicitly declared in a manifest (as is the case for normal Android). See #4736 for more context.
  • PackageManager
    • PackageManager is moving to returning defensive immutable copies of its internal data (as on a real device). A series of new testing APIs have been added to modify the package under test; see PackageManager.addOrUpdateActivity() and removeActivity(), plus Service, ContentProvider, and BroadcastReceiver equivalents [issue #4489].
    • Implement PackageManager.isSafeMode() [issue #4526].
  • ShadowDisplayManager.getSaturationLevel() is now an instance method [issue #4522].
  • Telephony
    • Add slotId based getImei() and getMeid() to TelephonyManager [issue #4521].
    • Add the ability to prevent certain networks from being updated in tests [issue #4515].
    • Implement TelephonyManager.getListenersForFlags in tests [issue #4469].
    • Implement TelephonyManager.getVisualVoicemailPackageName() [issue #4444].
  • Bluetooth
    • Test APIs for BluetoothSocket and BluetoothServerSocket connections [issue #4510].
    • Implement BluetoothLeAdvertiser [issues #4478 and #4454].
    • Implement BluetoothHeadset.getConnectedDevices(), getConnectionState(), and sendVendorSpecificResultCode(), with test APIs [issue #4442].
    • Add ability to send BluetoothGattCallback connection state change updates [issue #4584].
  • Implement ActivityManager#getCurrentUser() [issue #4483].
  • UserManager
    • Implement UserManager.getUserSerialNumber() [issue #4501].
    • UserManager#addUser returns a UserHandle to the user it creates [issue #4449].
    • Add isRestrictedProfile() and setIsRestrictedProfile() [issue #4554].
  • Implement Context.sendBroadcastAsUser [issue #4486].
  • Implement WindowManagerImpl#removeViewImmediate(View) [issue #4447].
  • Implement SensorManager.registerListener(): [issue #4446].
  • Implement NetworkScoreManager.disableScoring() and isScoringEnabled() to [issue #4436].
  • DevicePolicyManager now enforces password restrictions [issues #4532, #4545, and #4539].
  • Implement UiModeManager [issue #4548].
  • Implement AccessibilityManager#addAccessibilityStateChangeListener(AccessibilityStateChangeListener, Handler) [issue #4448].
  • Implement ParcelFileDescriptor.createReliablePipe method [issue #4562].
  • Move intent filters to their own lists and out of the Package [issue #4488].
  • Implement WifiRttManager and RangingResult [issue #4561].
  • Add test API to toggle a Sensor wake-up mode [issue #4558].
  • Add PowerManager.WakeLock getTimesHeld() test API to count number of times the wakelock was held [issue #4551].
  • Adds basic MediaCodec and MediaMuxer shadows to robolectric. The MediaCodec shadow implements basic passthrough asynchronous encoding, and the MediaMuxer shadow muxes input bytes directly to the file without modification [issue #4550].
  • Update to ShadowDevicePolicyManager to allow uses-policy granting [issue #4546].
  • Modify ShadowParcel to throw an Error instead of RuntimeException to discourage [issue #4528].
  • Don't autocreate activities in LocalActivityInvoker anymore [issue #4582].
  • Don't automatically generate default ActivityInfo whenever asked [issue #4580].
  • Implements WebView.removeJavascriptInterface [issue #4575].
  • Update to ShadowDevicePolicyManager to set storage encryption [issue #4563].

Configuration

  • There are some small changes to the way Android SDK jars are located; see (LegacyDependencyResolver javadoc)[http://robolectric.org/javadoc/4.2/org/robolectric/plugins/LegacyDependencyResolver.html] for details [issue #4599].

Bug Fixes

  • The android system context is no longer a parent of the application context [issue #4481].
  • Fix LocalActivityInvoker.recreateActivity. Before this change, it called Activity.onRetainNonConfigurationInstance() directly to obtain nonConfigInstance for the activity. This should've called indirectly from Activity.retainNonConfigurationInstances(). retainNonConfigurationInstances() also creates nonConfigInstances for fragments to prepare for the host activity recreation [issue #4511].
  • Fix timeout in FontsContract.getFontSync() caused because Context.canLoadUnsafeResources() now returns false since the context isn't a system context [issue #4517].
  • Fix handling of persisted preferred activities [issue #4480].
  • Fix processName setting and add few more reasonable defaults when installing new package [issue #4465].
  • Add permission check to LocationManager.setLocationEnabledForUser [issue #4500].
  • No longer reset the data position after unmarshalling a ShadowParcel [issue #4468].
  • Fix NPE Robolectric when a failure occurs before shadows are set up [issue #4467].
  • Set AppBindData#processName consistently with ApplicationInfo#processName [issue #4537].
  • Throw NameNotFoundException from Context.createPackageContext for non-existing packages [issue #4527].
  • Synchronize access to ShadowPendingIntent and ShadowUsageStatsManager fields [issue #4520].
  • Fix Activity#isChangingConfigurations() returning false during the recreation [issue #4540].
  • Fix equality in ShadowNetwork [issue #4464].

Deprecations and Removals

  • FsFile et al. have been removed in favor of java.nio.file.Path [issue #4265].
  • ShadowPackageManager.addResolveInfoForIntent is deprecated; add explicit activity declarations in your manifest, or use ShadowPackageManager.addOrUpdateActivity(ActivityInfo) [issue #4489].
  • Deprecate Robolectric#setupActivity in favor of ActivityScenario [issue #4564].

Internal Changes

  • Tests are now run on a dedicated thread for each SDK [issue #4559].
  • Resolve AARs like the android plugins do (kind of) [issue #4279].
  • Reflector objects should unwrap invocation exceptions [issue #4361].
  • Fast private method invocation [issue #4315].
  • Add support for static methods and fields to Reflector [issue #4351].
  • Fix Reflector class definition in Java 11 [issue #4456].
  • Support Java 9 [issue #4400].
  • Robolectric now builds successfully on Windows, though a few tests still fail [issue #4293].
  • Extensible configuration system [issue #4519].
  • Switch circleci to API 28 image. Fix SDK install license fail [issue #4541].
  • Changes to support Java 9 [issue #4452].
  • TypedArray doesn't need a shadow in binary mode [issue #4470].
  • Extract Sdk from SdkConfig [issue #4394].
  • Clean up SdkProvider interface [issue #4513].
  • Move PerfStatsReporter to pluginapi [issue #4471].
  • PerfStatsCollector retains min and max timing info for events [issue #4552].
  • Remove DefaultConfigMerger [issue #4549].

Known Issues

  • Activities must now be explicitly declared in a manifest (as is the case for normal Android); however, Android Gradle Plugin doesn't currently merge a test manifest. See #4736 for more context and #4727 for a workaround.
  • Robolectric 4.2 doesn't work on Windows in some cases [issue #4603 et al.].
  • Android Gradle Plugin 3.2.1 and 3.3 report the following warning, which may be safely ignored: WARNING: The option setting 'android.enableUnitTestBinaryResources=true' is experimental and unsupported.. Android Gradle Plugin 3.4 will resolve this issue.
  • Android Gradle Plugin 3.2.1 does not work on Windows; use 3.3 instead [issue #3955].

Compatibility

  • Android Studio/Android Gradle Plugin 3.3 or 3.4 Beta
  • Android SDK 28 (includes support for testing against SDKs from 16 on)

Use Robolectric:

testCompile "org.robolectric:robolectric:4.2"

Find more details here. Report issues here. Enjoy!