TDD Tips

原创 2011年01月09日 17:29:00

How to design the testable software? You may always find some best practices about designing for scalable, extensible or maintainable. To be testable, the best way should be TDD. Followings are some tips from my real practices on TDD.

1 TDD is design process; it let you design for testing, naturally

Write the test firstly, it does not only help you find the bugs; but the most important point is to let you design for test naturally.

Also you should keep in mind, tests not only help you find bugs, but also protect your codes; when some changes impact on your existing codes, the tests will be broken.

 

2 Keep the implementation simple

Keep your implementation simple, just let the test pass. The complex implementation may introduce the logics or codes not covered by the tests, even leads some codes not testable.

 

3 TDD in each scope.

You may get to know the concept ATDD (acceptance test driven development). TDD could be used in every phase of the development and by the different granularity.

To ATDD, you could consider on using some existing framework such as FIT, these frameworks will be bridge between business logic and implementation logic.

Recently, the concept BDD (behavior driven development) is introduced to the ATDD process, so the BDD frameworks such as JBehave is also the good choice.

 


Different TDD process could be nested and should be nested don’t let your step too large.

 

4 keep each step small enough

Always keep each step small to avoid introducing the untestable codes or logics and pass each test quickly.

 

 

6 Always refactor

This step is always overlooked in TDD process; however it is the very important step. Also, never forget refactor should involve all your tests.

 

Why can't write test firstly?

 1.not think how to meature the codes

2. The current step maybe too large, should separate into small ones

3. The codes with ugly dependencies

 

Chao Cai (蔡超)

Sr. SDE

Amazon.com

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

EXCEL_CM_PLAN_TDD_RADIO

  • 2015-06-12 00:29
  • 11.72MB
  • 下载

TDD、BDD、DDD简介

1. TDD TDD指的是Test Drive Development,很明显的意思是测试驱动开发,也就是说我们可以从测试的角度来检验整个项目。大概的流程是先针对每个功能点抽象出接口代码,然后编写单...

tdd-calculator_V2.0

TDD

TDD:测试驱动开发(Test Driven Development),是通过测试定义所要开发的功能的接口,然后实现功能的开发过程。TDD的基本思路 通过测试来推动整个开发的进行,但测试驱动开发并不...

TDD读书报告

  • 2012-03-03 13:34
  • 34KB
  • 下载

测试驱动开发-TDD(1)

测试:作为动词,它是评估的意思;作为名词,它是导致最终是接受还是不接受的过程。 测试是相互独立的。 测试列表,就跟你生活中记录你的工作计划一样。 测试优先:你应该在什么时候编写测试呢?在你编写要...

FDD与TDD的综合比较

  • 2015-07-22 17:14
  • 10KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

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