加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

敏捷开发--TDD

发布时间:2020-12-13 19:56:34 所属栏目:百科 来源:网络整理
导读:TDD (Test Driven Development):顾名思义测试驱动开发,在没有开发之前,先写test case,写出来的code要满足test case. Test Driven Development is the strategy of writing tests along the development process. These test cases are written in advance of

TDD (Test Driven Development):顾名思义测试驱动开发,在没有开发之前,先写test case,写出来的code要满足test case.

Test Driven Development is the strategy of writing tests along the
development process. These test cases are written in advance of the code that is
supposed to satisfy them.
A single test is added,then the code needed to satisfy the compilation of this test and
finally the full set of test cases is run to verify their results.

TDD的流程:

1. 写test cases,实际上写test case的过程就是理解需求的过程,写test case的过程中会驱使我们去想清楚如何去开发,使我们能使提前想到一些可能会出现的问题.

2.run test cases: 为了能让所有的test cases run成功,不断的完善开发代码

3. 重构代码: 当所有的test case pass,重构代码,清理没有用的,是代码更加干净紧凑; 重构完成没有可以再优化的地方,而且所有的test cases pass的时候,任务就完成啦

这个跟完全颠覆了我们先开发再测试的观点,这样做有什么好处捏?

1. 让开发过程变成已结果为主导,让需求更明确,不会开发出没有用的代码

2. 当要对代码做出改变时,会很清楚的知道会影响系统的那些部分

对于TDD的实用性不敢妄加评论,也没有在实际项目中用到这种模式。这种模式成熟型的公司有可能会用到, 创业型的公司应该不会使用,因为代码量差不多多了一倍,风险也因此增加。希望以后可以在个小的项目中应用,感受一下他的魅力.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读