Robolectric测试环境移除stetho
来源:互联网 发布:golang mongodb 查询 编辑:程序博客网 时间:2024/06/05 03:35
Stetho是非常不错的调试工具,Robolectric是在单元测试中模拟android运行环境的工具。
创建shadow class
正常情况下,我们是这样使用的:
testCompile "org.robolectric:robolectric:3.1" debugCompile 'com.facebook.stetho:stetho:1.3.1'
这时候可以用Robolectric的shadow类模拟一个空的替代。
先把stetho的相关操作都集中到一个类
public class StethoUtil { static public void init(Application application){ Stetho.initializeWithDefaults(application); OkHttp.create(OkHttp.getDefaultBuilder().addNetworkInterceptor(new StethoInterceptor())); }}
创建shadow class
@Implements(StethoUtil.class)public class ShadowStethoUtil { static public void init(Application application){ }}
@RunWith(RobolectricGradleTestRunner.class)@Config(constants = BuildConfig.class, sdk = 23, shadows = ShadowStethoUtil.class)public class UserManagerTest {...}
这样,在测试环境中执行的就是ShadowStethoUtil了
0 0
- Robolectric测试环境移除stetho
- Android Studio Robolectric测试环境配置
- 【Android】robolectric测试实践
- Robolectric 环境搭建(Eclipse)
- Robolectric环境搭建小记
- Android Robolectric 测试框架探究
- Android测试框架之Robolectric
- Robolectric测试框架使用文档
- Robolectric
- Robolectric 测试你的Android代码
- 使用Robolectric对android程序实现自动化测试
- Android 系列 3.5使用Robolectric和JUnit测试4
- Robolectric环境搭建——运行RobolectricSample示例工程
- Android Studio环境下Android单元测试(基于Robolectric+Mockito)
- 使用okhttp和stetho自由地测试网络请求
- robolectric relative
- Robolectric使用
- Robolectric介绍
- dom4j解析xml文档
- 4.文字在div垂直居中的方式
- VB查询数据库用于Ext.NET的Store
- TCP选项之SO_RCVBUF和SO_SNDBUF
- application/x-www-form-urlencoded
- Robolectric测试环境移除stetho
- 最详细的Log4j使用教程
- redis脚本:查看近一小时内有哪些用户登录过redis
- 项目管理心得:一个项目经理的个人体会、经验总结
- sql基本语句转载
- IPv4与IPv6的互操作性、守护进程和inet超级服务器、高级I/O函数
- Thread Pool
- ListView+GridView实现行列不确定的表格
- 从程序员到项目经理