Looking at TDD from newbie’s point of view<o:p></o:p>
<o:p> </o:p>
<o:p></o:p>
fantian830211@163.com<o:p></o:p>
<o:p> </o:p>
Preface<o:p></o:p>
Many times heard people says that test is vitally important for software developing and kinds of test methodology, after have been developing Java web application for over a year, I deeply realized that test is the combination of experience and technology. Last Friday I accepted JUnit training, the training showed us TDD and the teacher shared his experience of test, it is excellent. Now I will share what I learnt recently.<o:p></o:p>
What is TDD?<o:p></o:p>
TDD is abbreviation of Test-Driven Development, is a core technology of XP (eXtremely Programming), but this methodology can do many help for testing our software even though it not being developed in XP process. Here you may doubt what XP is, I would tell you just Google it.<o:p></o:p>
XP philosophy<o:p></o:p>
Any methodology has its own philosophy, so XP too. Communication, Simplicity, Feedback and Courage are the four values sought out by XP programming. We can see the human character of XP, cannot you?<o:p></o:p>
TDD steps<o:p></o:p>
We can do our TDD by doing the following steps:<o:p></o:p>
First, understand and simplify the requirements<o:p></o:p>
Second, think over you test-driven and complete it<o:p></o:p>
Third, complete your business classes or methods which are being tested by your test-driven<o:p></o:p>
Finally, run you test-driven and make the test pass<o:p></o:p>
If the requirements were changed, just do the same steps mentioned above<o:p></o:p>
If the code smells bad, refactoring your code.<o:p></o:p>
<o:p> </o:p>
Actually, here refactoring is the most important step, and it need developers experienced. We may ask what is refactoring, there is a book--- Refactoring by Martin Flow showed us what it really is.<o:p></o:p>
Why it is better?<o:p></o:p>
Now we might have seen that TDD is not only for test, but also for design. It is better for the following reasons:<o:p></o:p>
First, most programmer would prefer code to documents, and the test-driven is a good idea to solve the problem.<o:p></o:p>
Second, test-driven make programmer do their work confidently. They can test they code any time and have the reason believe that the code is right.<o:p></o:p>
Yes, they must be more, but the first statement in this section is enough. TDD is not only for test, but also for design. <o:p></o:p>
Some rules<o:p></o:p>
First, developers must write test-driven for his(or her) class or methods.<o:p></o:p>
Second, write test-driven for classes or methods you believe must be tested not all methods or classes.<o:p></o:p>
Third, run you test-driven any time and make your code clean.<o:p></o:p>
Forth, refactoring your code if it looked ugly anytime.<o:p></o:p>
Mr. Robert C. Martin showed us his rules:<o:p></o:p>
You are not allowed to write any production code unless it is to make a failing unit test pass. <o:p></o:p>
You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. <o:p></o:p>
You are not allowed to write any more production code than is sufficient to pass the one failing unit test.<o:p></o:p>
See more and detail on his site, there is a link in the bibliography of this article.<o:p></o:p>
Using JUnit in TDD<o:p></o:p>
Keep the bar green to keep your code clean, it is JUnit. It is a tool gives us the ability to write our test-driven conveniently. Reduce percent of mistakes in our test-driven. It is easy to use and make our test-driven develop more efficiently. Of course, JUnit is not enough, there are kinds of auto-tools can work with JUnit. Just find out our Mr. right.<o:p></o:p>
Using JUnit in out-sourcing<o:p></o:p>
Condition is special in out-sourcing development, especially in out-souring for Japanese, here developers have been deprived their last freedom. When we make our decision use JUnit to test our program, the following questions should have been thought over carefully.<o:p></o:p>
First, get agreement of JUnit from our customer.<o:p></o:p>
Second, customer would like to pay for test-driven<o:p></o:p>
Third, customer wouldn’t mind there are no test documents<o:p></o:p>
Forth, make sure our team has the energy and experience<o:p></o:p>
Fifth, test is for experienced member, not newbie<o:p></o:p>
Six, for GUI test, auto-test won’t work any longer<o:p></o:p>
Experiences<o:p></o:p>
Auto test is a lie for lazy developers, anytime and anywhere, men will be ever the core. Think everything over carefully.<o:p></o:p>
Summary<o:p></o:p>
I am afraid the article a bit off topic, but I don’t think it won’t do any harm to the goal of showing experience on testing. There is nothing can be absolutely depended on except our self, our knowledge, our experience and our intelligent mind.<o:p></o:p>
Bibliography<o:p></o:p>
http://www.butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd<o:p></o:p>
http://blog.csdn.net/rmartin/archive/2006/08/17/1089322.aspx <o:p></o:p>
http://www-128.ibm.com/developerworks/cn/linux/l-tdd/<o:p></o:p>
http://pag.csail.mit.edu/continuoustesting/<o:p></o:p>
http://caterpillar.onlyfun.net/Gossip/JUnit/JUnitGossip.htm<o:p></o:p>
<o:p> </o:p>
分享到:
相关推荐
ME909S-821模块基于LTE技术,支持FDD/TDD-LTE和UMTS/HSPA+网络制式,提供高速数据传输能力。其硬件特性包括: 1. 支持多种频段:覆盖全球主要运营商的4G频段,确保在全球范围内具有良好的网络兼容性。 2. 强大的处理...
测试驱动开发(Test-Driven Development,简称TDD)是一种软件开发方法,强调在编写实际功能代码之前,先编写测试用例。这种方法的核心理念是“先写测试,再写代码”。TDD通过引入测试来引导软件设计,使得开发过程...
### 使用PHPUnit进行TDD驱动开发 #### 一、引言 测试驱动开发(TDD, Test-Driven Development)是一种软件开发方法论,它要求在编写实际功能代码之前先编写测试用例。通过这种方式,可以确保代码的质量,并且有助...
### UMTS-TDD 手册知识点解析 #### 核心知识点概述 本文档主要针对的是**NS2网络仿真软件**中的**UMTS-TDD**(Universal Mobile Telecommunications System - Time Division Duplex)仿真方法进行了深入细致的介绍...
"GSM TDD 噪声分析" GSM TDD 噪声是一种常见的干扰现象,发生在 GSM 通信系统中的射频部分。这种噪声的产生是由于天线辐射出的射频能量和 PA 突发工作时带动电源的干扰。为了减少这种噪声的影响,我们可以采用一些...
华为LTE TDD系统原理培训PPT文档
单元测试与TDD实践 **一、单元测试之测试目的** 单元测试,作为软件开发过程中的重要环节,其核心目标在于确保代码的质量、可维护性和可扩展性。它通过独立测试软件中的最小可测试单元,如函数或方法,来验证其...
【Laravel开发-TDD(测试驱动开发)】 在软件开发领域,TDD(Test-Driven Development,测试驱动开发)是一种编程实践,它强调先编写测试用例,再编写实现功能的代码。Laravel,作为一款流行的PHP框架,高度支持TDD...
### 嵌入式TDD:测试驱动开发在嵌入式C中的应用 #### 引言 测试驱动开发(Test-Driven Development,简称TDD)是一种软件开发方法论,其核心理念是在编写实际代码之前先编写测试用例。这种方法不仅有助于确保代码...
**Ruby-TDD实战:Test Driven Development in Action** 在软件开发领域,Test-Driven Development(TDD)是一种编程实践,它强调先编写测试用例,然后编写满足这些测试的最小功能代码。Ruby作为一种动态、灵活的...
《Test Driven: Practical TDD and Acceptance TDD for Java Developers》是一本专注于Java开发者进行测试驱动开发(TDD)和验收测试驱动开发(Acceptance TDD)的专业书籍。这本书以PDF英文版的形式提供,旨在帮助...
在C#编程环境中,测试驱动开发(Test-Driven Development,简称TDD)是一种软件开发方法论,它强调先编写测试用例,然后根据这些测试用例来实现功能代码。这种做法有助于确保代码的质量,减少错误,并提高开发效率。...
测试驱动开发(TDD)是一种软件开发方法,它要求开发者首先编写失败的单元测试用例,然后再编写足够的代码以使测试通过。接下来,开发者会对代码进行重构以改善设计,同时确保测试依然能够通过。这个过程循环进行,...
C语言的TDD参考示例代码,主要包含了书中所参考的源代码
- **Chapter 13: The Root of all Evil** - 讨论了错误处理的重要性及其在 TDD 中的应用。 - **Chapter 14: Addition, Finally** - 通过加法运算的例子展示了如何逐步完善功能。 - **Chapter 15: Make It** - 解释了...
### TDD读书报告知识点梳理 #### 一、了解和认识TDD - **定义**: 测试驱动开发(Test-Driven Development, TDD)是一种软件开发方法论,它要求开发人员在编写功能代码前先编写测试代码,以确保功能代码的质量。 - ...