Android测试框架概述

按测试规模从小到大,测试可以分为三个层级:Unit Tests, Integration Tests, UI Tests
按测试运行环境不同,测试可分为两个环境:Local unit tests, Instrumented unit tests

参考Google测试指引


测试规模分类

Unit Tests

  • Robolectric
  • Mockito
  • Instrumented unit tests

Integration Tests

多单元组成的组件测试,包含service tests, integration tests, and hermetic UI tests


UI Tests

AndroidJUnitRunner使测试得以运行在Android设备上,其支持以下测试工具:

  • JUnit4 Rules: 管理测试关联组件的生命周期,如activity和service。
  • Espresso:管理应用内的交互
  • UI Automator:当测试需要与系统交互时,才会考虑使用UI Automator(考虑系统版本变更导致的工作量)。

测试环境分类

Local unit tests 本地单元测试

使用最流行的Java单元测试框架JUnit4;
当测试对象对Android framework有依赖时,可使用Mockito或其它工具模拟这些Android framework对象。


Instrumented unit tests 仪器测试

测试运行在Android设备或虚拟机上
仪表测试需要一个JUnit test runner(AndroidJUnitRunner)和测试APIs提供者(Espresso, UI Automator)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值