Test Driven or Test First?

转载 2004年12月30日 12:58:00
I recently got into a discussion with Cobbie Behrend, following on from some comments I’d made about test-driven development. I’d said that I rarely do test-first, but I often do test-driven coding.

Cobbie pushed me to distinguish between them, particularly in light of references on the Object Mentor site, the C2 wiki, and other sites, which seem to equate the two.

I disagree—test-first is different than test-driven development.

For me, test-driven development is an important way of thinking about coding. It’s about using tests to gain perspective on your design and implementation. You listen to what the tests are telling you, and alter to code accordingly. Finding it hard to test something in isolation? Refactor your code to reduce coupling. Is it impossible to mock out a particular subsystem? Look at adding facades or interfaces to make the separation cleaner. Tests drive the design, and tests verify the implementation.

Test-first development takes this a step further. In test-first, you never write a line of production code until you first have a failing test that will be "fixed" by the code you write. Want to write a new class? First write a test that instantiates it, watch the test fail, and then implement the class body to fix the broken test.

Test-first development is a subclass of test-driven development. It has every benefit of test-driven development, and then adds a ritual component of testing and coding in a certain order. The intent of the ritual is to ensure that tests are always produced.

For me, test-driven development is an essential part of coding. Test-first coding, however, often strikes me as unnecessarily high-church. So I distinguish the two, in the same way that I distinguish agile methods from eXtreme Programming. Test-driven is an important, almost universal practice. Test-first is a particular implementation, and it isn’t always applicable.

I don’t know if this helps Cobbie in his search for meaning, though…


集训第二周周四,做出来了7道题目,题目非常水,还有几道没有A出来的也不难,完了花点时间水一下,a过的题目贴在这里。没有a的后面补上。 比赛链接:http://acm.hust.edu.cn/vj...
  • y990041769
  • y990041769
  • 2014年01月14日 19:04
  • 14236

PAT 解题报告

PAT 1070Mooncake (25)时间限制100 ms内存限制32000 kB代码长度限制16000 B判题程序Standard作者CHEN, YueMooncake is a Chinese...
  • abcjennifer
  • abcjennifer
  • 2014年02月20日 12:57
  • 13710

SoapUI 测试Data Driven(数据驱动测试)

What is Data Driven Testing ? 维基百科:https://en.wikipedia.org/wiki/Data-driven_testing TutorialsPoi...
  • Temanm
  • Temanm
  • 2016年09月22日 20:09
  • 2075


汇编test和cmp区别 看过破解教程,都知道test,cmp是比较关键,可是我一直不清楚它们究竟是怎么比较的,最后下决心找了很多资料,和大家一起把它们弄清楚. 首先看看:...
  • thanklife
  • thanklife
  • 2013年09月04日 15:57
  • 6534

go test 命令介绍

go testgo test是go语言自带的测试工具,其中包含的是两类,单元测试和性能测试 通过go help test可以看到go test的使用说明: 格式形如: go test [-c] ...
  • csapr1987
  • csapr1987
  • 2015年04月08日 12:21
  • 2037

java中 @Test注解的使用和其他成员

package com.starry.exersice; import org.junit.After; import org.junit.AfterClass; import org.junit....
  • starry7953810
  • starry7953810
  • 2017年06月12日 19:04
  • 362


spring——依赖注入DI(spring-test方式) 本文主要介绍如何实现spring 的依赖注入,并且浅显的讲述一下注入需要注意的事项。 1、创建一个maven项目 mvn archet...
  • wild46cat
  • wild46cat
  • 2017年05月01日 12:47
  • 511

go test命令参数问题

go test命令参数问题在使用go test对go代码进行单元测试的时候,遇到关于命令参数的问题,google了一下,没有找到很好的说明,其实就是一些细节而已。问题是这样的,在进行单元测试的时候,我...
  • kangaroo835127729
  • kangaroo835127729
  • 2016年03月18日 15:04
  • 3013

shell script学习(三)判断式的使用:test命令以及[ ]

shell script中的判断式,顾名思义就是判断一个式子是否满足一定的条件。在script中有如下几种实现方式: 1、使用test命令 先举个简单的例子,比如说判断在当前目录下判断一个文件scri...
  • u011321908
  • u011321908
  • 2014年01月21日 10:39
  • 4128


  • hsd2012
  • hsd2012
  • 2016年04月25日 16:08
  • 1183
您举报文章:Test Driven or Test First?