About Unit Test In Android(安卓单元测试研究,附技术分享ppt)

  1. what is unit test?
    单元测试中的单元是一个系统或一个程序的组成部分,单元测试就是要对这些组成部分进行独立地、隔离地以某种约束和规则进行的测试,以发现每一部分的问题或者确定该部分不存在问题。

    Essentially, a unit test is a method that instantiates a small portion of our application and verifies its behavior independently from other parts. A typical unit test contains 3 phases: First, it initializes a small piece of an application it wants to test (also known as the system under test, or SUT), then it applies some stimulus to the system under test (usually by calling a method on it), and finally, it observes the resulting behavior. If the observed behavior is consistent with the expectations, the unit test passes, otherwise, it fails, indicating that there is a problem somewhere in the system under test.

    也即,单元测试实例化系统的一小部分,然后相对独立地确定此部分的行为是否正确。

  2. why unit test?

    The goal of Android unit test is to isolate each part of the program and show that the individual parts are correct. A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits.—Wikipedia

    将系统的不同模块分离进行测试,有利于不同team和不同团队成员协作,不同team可以独立地完成各自的任务,而不用相互block,对于同一team的不同成员也同样适用。

  3. test theory

    • 系统要分层或者分模块
      不同的Part可能有不同的特征,应采用不同的测试工具和测试方法
    • 最小化原则
      如果一个测试没有pass的原因有多种,涉及的系统模块不止一个,那么这个测试不符合最小化原则,不能用于快速地发现问题。
    • 系统的各模块之间要解耦
      如果系统各模块之间的耦合过于严重,在实例化预测试Part时,需要Mock多个其他Part的组件,增加了
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值