Performance degradation when upgrading from Robolectric 3.0 to 3.1 #2522

dsn5ft opened this Issue Jun 20, 2016 · 2 comments


None yet

2 participants

dsn5ft commented Jun 20, 2016


We are trying to upgrade to Robolectric 3.1 from version 3.0 which has been very stable and predictable. We currently have 700 tests that take about 4 minutes to run. We use Dagger and have a TestModule that uses Mockito so we can mock our Activity/Fragment dependencies. After upgrading to 3.1, the tests are about 10 times slower or just hang indefinitely.

One thing we noticed is that Robolectric now seems to layout ViewGroups that it was not laying out before. In order to compensate for this, we were manually calling ViewGroup.layout() to test Activities/Fragments that use RecyclerViews, as suggested in this post -

Can you confirm that this was changed in Robolectric 3.1 and if so, do you think it could cause tests to take significantly longer. Also, were there any other major changes to the library's internals that you think could cause memory/performance issues?


Yes there is a performance regression that has been fixed at head. We'll push out a 3.1.01 with the fix in it, making this a duplicate of #2328

Also yes, Robolectric now calls a layout pass as would real Android, with a call to "dispatchResized".

@jongerrish jongerrish closed this Jun 20, 2016
dsn5ft commented Jun 20, 2016

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment