ATDD和TDD的区别是什么?

最近看到一个新名词“ATDD”,全称“Acceptance Test Driven Development ”,中文称“验收测试驱动开发”。ATDD和TDD的区别是什么呢,查了一些资料,我的理解如下:

先介绍一下TDD,引用Wikipedia上的关于TDD的介绍:

Test-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: first the developer writes an (initially failing) automated test case that defines a desired improvement or new function, then produces the minimum amount of code to pass that test, and finally refactors the new code to acceptable standards.

TDD只涉及到Developer(开发者),只能算个人工作方式的改变。而现代软件开发,往往都是“产品经理(或业务)、测试人员(或QA)、开发人员”三者合作的成果,如果开发人员对业务需求理解的不正确,那么写出的测试用例也是错的,这个问题是TDD解决不了的。中文Wikipedia上对于TDD缺点的描述,也把这一问题列在第一位:

image

ATDD又如何解决这个问题呢?《Explore It!: Reduce Risk and Increase Confidence with Exploratory Testing》这本书的作者Elisabeth Hendrickson给出了下面的解释:

Acceptance Test Driven Development (ATDD) is a practice in which the whole team collaboratively discusses acceptance criteria, with examples, and then distills them into a set of concrete acceptance tests before development begins. It’s the best way I know to ensure that we all have the same shared understanding of what it is we’re actually building. It’s also the best way I know to ensure we have a shared definition of Done.

整个团队(包括上面提到的三方成员)在开发工作开始之前,一起讨论、制定每个任务(或者用户故事)的验收标准,并提取出一组验收测试用例。这么做好处在于:

  1. 大家一起讨论验收标准和测试用例保证了对业务需求一致的理解。(这一点实际是所有开发环节中都需要关注的问题
  2. 通过形成测试用例,使标准成为可执行的内容,而不是虚的指标。

国内公司一般项目开发进度很紧,大部分公司开发和测试工作由不同的人来负责,完全照搬TDD流程来开发成本过高。我更建议开发人员使用自动化测试技术编写验收测试用例,只要验收测试用例能够跑通了,就可以提交测试。

参考:

  1. Test-driven development
  2. 测试驱动开发
  3. BDD就是做得比较好的ATDD吗?
  4. Acceptance Test Driven Development (ATDD): an Overview
  5. 验收测试驱动开发(ATDD)
  6. 【转】TDD和ATDD的转化?
原文地址:https://www.cnblogs.com/EthanCai/p/3174920.html