Test Double

转载 2015年07月10日 10:34:52

   Test Double is a generic term for any case where you replace a production object for testing purposes. There are various kinds of double that Gerard lists:

  • Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
  • Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (anInMemoryTestDatabase is a good example).
  • Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test.
  • Spies are stubs that also record some information based on how they were called. One form of this might be an email service that records how many messages it was sent.
  • Mocks are pre-programmed with expectations which form a specification of the calls they are expected to receive. They can throw an exception if they receive a call they don't expect and are checked during verification to ensure they got all the calls they were expecting.

http://www.martinfowler.com/bliki/TestDouble.html

Test Double, 以及为什么Mock之争都争错了方向

全量测试又慢又难以定位错误, 其所需的测试环境的维护成本也很高. 解决方案就是化整为零分别测试. 然而引入新的问题: 测某个"部分"时所需的依赖如何满足. 解决方案是一组被称为"测试替身(Test D...

测试问题域: Test Double, 以及为什么Mock之争都争错了方向

全量测试又慢又难以定位错误, 其所需的测试环境的维护成本也很高. 解决方案就是化整为零分别测试. 然而引入新的问题: 测某个"部分"时所需的依赖如何满足. 解决方案是一组被称为"测试替身(Test D...
  • chelsea
  • chelsea
  • 2012年01月04日 21:43
  • 4066

《xUnit Test Patterns》学习笔记6 - Test Double

我不知道Test Double翻译成中文是什么,测试替身?Test Double就像是陈龙大哥电影里的替身,起到以假乱真的作用。在单元测试时,使用Test Double减少对被测对象的依赖,使得测试更...

Double click to play music

  • 2017年11月01日 01:05
  • 42KB
  • 下载

Java之浮点四则运算工具类-(double/float转化为BigDecimal)

package zmx.util; import java.math.BigDecimal; public class ArithUtil {  // 源文件Arith.java:  /** ...

fullbridge_double_frequency3

  • 2016年01月11日 17:09
  • 70KB
  • 下载

Double-Take_Backup_Implement_V5_2

  • 2014年03月17日 15:41
  • 1.93MB
  • 下载

C++中将string类型转换为int, float, double类型 主要通过以下几种方式:

C++中将string类型转换为int, float, double类型 主要通过以下几种方式: # 方法一: 使用stringstream stringstream在int或float类型转换为...

Impedans_Double_Probe_Brochure_V1.0

  • 2012年12月07日 21:20
  • 908KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Test Double
举报原因:
原因补充:

(最多只允许输入30个字)