RobolectricGradleTestRunner vs RobolectricTestRunner.class

自闭症网瘾萝莉.ら 提交于 2019-12-06 20:43:25

问题


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.


回答1:


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/



来源:https://stackoverflow.com/questions/36486736/robolectricgradletestrunner-vs-robolectrictestrunner-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!