Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RobolectricGradleTestRunner vs RobolectricTestRunner.class

Tags:

robolectric

In roboelectric when you write your test class you have declare the @RunWith annotation of which there is RobolectricGradleTestRunner and RobolectricTestRunner.class. What is the difference and which one should we use ? Why is there 2 in the first place. If I use RobolectricTestRunner then it does not work for me it says some weird error like :

"java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity."

However this seems to go away if I use RobolectricGradleTestRunner.

like image 884
drlobo Avatar asked Apr 07 '16 20:04

drlobo


1 Answers

RobolectricTestRunner was first and is for maven based projects.

RobolectricGradleTestRunner was for gradle based projects because some paths have changed. Since robolectric 3.1.1 this is not more necessary and is now deprecated.

For more details see also http://robolectric.org/getting-started/

like image 190
nenick Avatar answered Jan 03 '23 20:01

nenick