在 roboelectric 中,当您编写测试类时,您已经声明了 @RunWith 注释,其中有 RobolectricGradleTestRunner 和 RobolectricTestRunner.class。有什么区别以及我们应该使用哪一种?为什么首先有2。如果我使用 RobolectricTestRunner 那么它对我不起作用,它会显示一些奇怪的错误,例如:
"java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity."
然而,如果我使用 RobolectricGradleTestRunner,这似乎就会消失。
RobolectricTestRunner是第一个,适用于基于 Maven 的项目。
RobolectricGradleTestRunner适用于基于 gradle 的项目,因为某些路径已更改。
从 robolectric 3.1.1 开始,这不再是必要的,现在已被弃用。
有关更多详细信息,另请参阅http://robolectric.org/getting-started/ http://robolectric.org/getting-started/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)