测试驱动开发(Test-Driven Development)

    最近看了下测试驱动开发(Test-Driven Development), 第一部分用一个资金实例讲解测试驱动开发模式(采用java编写示例),感觉挺不错的。

   不过这种模式需要编写跟功能代码量相当的测试代码;一步一步的测试保证,在大系统中修改代码尤为重要。


 测试驱动开发的过程如下:

1. 加入一个小的测试

2. 运行所有的测试,运行失败

3. 适当修改

4. 运行测试且成功

5. 重构,消除重复设计,优化设计结构


// 基本阶段

1. 不可运行 — 写一个不能工作的测试程序,一开始这个测试程序甚至不能编译

2. 可运行 — 尽快让这个测试程序工作,为此可以在程序中使用一些不合情理的方法

3. 重构 — 消除在让测试程序工作的过程中产生的重复设计,优化设计结构




针对Java语言,结合实例介绍测试驱动开发的方法。英文原版。 Test-driven development (TDD) is a development approach that relies on a test-first procedure that emphasises writing a test before writing the necessary code, and then refactoring the code to optimize it. The value of performing TDD with Java, one of the most established programming languages, is to improve the productivity of programmers, the maintainability and performance of code, and develop a deeper understanding of the language and how to employ it effectively. Starting with the basics of TDD and reasons why its adoption is beneficial, this book will take you from the first steps of TDD with Java until you are confident enough to embrace the practice in your day-to-day routine. You'll be guided through setting up tools, frameworks, and the environment you need, and will dive right in to hands-on exercises with the goal of mastering one practice, tool, or framework at a time. You'll learn about the Red-Green-Refactor procedure, how to write unit tests, and how to use them as executable documentation. With this book you'll also discover how to design simple and easily maintainable code, work with mocks, utilise behaviour-driven development, refactor old legacy code, and release a half-finished feature to production with feature toggles. You will finish this book with a deep understanding of the test-driven development methodology and the confidence to apply it to application programming with Java.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值