Test-Driven Development

Test-Driven Development (TTD) suggests that tests express the requirements with which the code must comply. This technique requires developers to write an automated unit test before writing feature code. As feature code evolves, automated tests provide immediate feedback to the developer and confirm, through true or false assertions, whether the code is behaving correctly. Because each feature of the software subsequently possesses a corresponding test or set of tests, higher confidence in the quality of the code is often the result.

 

The TDD process for developing features includes the following steps:

  • Write a test Developers are required to first develop a test that maps to the particular feature requirement.
  • Run all tests and see the new test fail Assuming that a set of tests exist across the code base, the new test should inevitably fail due to the lack of new feature code.
  • Write code that makes the test pass Feature code is developed to meet the requirement of the new test.
  • Run all tests and ensure all succeed Once the new feature code has been written, all tests should be executed again to ensure that new tests pass.
  • Refactor code Any code written to satisfy the previous steps may not be optimized and should subsequently be refactored to remove duplication or other code bloat.
  • Rinse and repeat Continue until there are no other requirements left to implement.

Other agile methodologies encourage developer-written unit tests, but TDD stands apart in its rigid view of testing before coding. TDD provides an interesting value proposition as a process that ensures high code quality; however, it does not provide an end-to-end framework for managing the software development life cycle. The goal of TDD is simply to be a framework for addressing customer requirements with software through an iterative approach to testing and coding.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值