`
dongbin
  • 浏览: 245715 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
社区版块
存档分类
最新评论

Test Driven Development 的一点思考

阅读更多

在学习Ruby on rails 的过程中,真正体验到了TDD和敏捷开发的乐趣,谈一点感想。

TDD与其说是Test Driven Development,不如说是Test Driven Design。

测试先行不同于先编码后测试的最重要一点就是,先编些测试能够在编码前就能思考类和方法的行为,期望输入和期望输出。设计和编码之间的鸿沟最大限度的得到了解决。

Test First 永远不等于"Test Earlier" !

许多自称理解了TDD的人自以为只要懂得了测试的重要性就行了,是否先行并不重要。

在我做项目的经验中,有时候在开发过程中没有写单元测试,而后来上面要求提交单元测试。这时候写单元测试简直就是一场噩梦,因为生米已经煮成了熟饭:

  1. 代码和J2EE API混在一起,JNDI, EJB , Servlet等。脱离容器没有办法测试。
  2. 各个模块之间藕合在一起。


这时候最好的交差办法就是做一些"Mock Unit Test",写一些假的单元测试,比如说get,set方法的测试。
最要命的是重构也非常困难,Unit Test 和Refactoring之间的关系就像鸡和蛋一样,没有Unit Test ,Refactoring其实就是痛苦的Debug过程。


而如果测试先行的话,整个开发过程中我的代码都是可单元测试的,只有这样才能保证敏捷开发的顺利进行。

分享到:
评论

相关推荐

    Test Driven Development: By Example

    ### Test-Driven Development (TDD): By Example #### 引言 在软件开发领域,测试驱动开发(Test-Driven Development, TDD)是一种被广泛推崇的方法论,它提倡在编写实际代码之前先编写测试用例。这种方法不仅能...

    iOS Test Driven Development.zip

    raywenderlich官方教程,iOS Test-Driven Development by Tutorials,包含源码。

    iOS Test Driven Development by Tutorials

    iOS Test Driven Development by Tutorials FIRST EDITION, Learn real-world test-driven development PDF & EPUB & SourceCode

    Test Driven Development with Django 无水印pdf

    Test Driven Development with Django 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请...

    测试驱动开发 Test-Driven Development

    Test-driven development replies to this contradiction with a paradox-test the program before you write it. A new idea? Not at all. Since the dawn of computing, programmers have been specifying the ...

    Test Driven Development, A J2EE example

    Test Driven Development: A J2EE Example by Russell Gold, Thomas Hammell and Tom Snyder ISBN:1590593278 Apress © 2005 (296 pages) Targeted at Java developers who want to learn how to use test-...

    Test-Driven Development with Python(2nd) epub

    Test-Driven Development with Python(2nd) 英文epub 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    Android Test Driven Development Tutorials - v1.zip

    在Android开发领域,Test Driven Development(TDD)是一种被广泛应用的编程实践,它强调先编写测试用例,再编写满足这些测试的代码。在这个"Android Test Driven Development Tutorials"资源包中,包含了PDF、ePub...

    Professional Test Driven Development with.Csharp

    ### 专业测试驱动开发与C# #### 知识点概览 1. **测试驱动开发(TDD)的概念** 2. **TDD的核心原则与实践** 3. **单元测试介绍** 4. **重构技巧** 5. **让测试指导开发流程** 6. **模拟外部资源** ...

    Test Driven Development_A J2EE Example

    测试驱动开发(Test-Driven Development, TDD)是一种软件开发方法论,它强调在编写功能代码之前先编写测试用例。这种方法有助于确保代码质量,并能提高软件的可维护性和可扩展性。本书《测试驱动开发:一个J2EE实例...

    Test-Driven Development: A Practical Guide

    **测试驱动开发(Test-Driven Development,TDD):实践指南** 测试驱动开发是一种软件开发方法,由Kent Beck在2003年提出并推广,它强调先编写测试,然后编写满足这些测试的代码。TDD的核心原则是“测试先行”,即...

    Test Driven Development in Ruby:

    Test Driven Development in Ruby: A Practical Introduction to TDD Using Problem and Solution Domain Analysis by Bala Paranj English | 5 Apr. 2017 | ISBN: 1484226372 | 288 Pages | PDF | 5.32 MB Learn ...

    Practical Test-Driven Development using C# 7.epub

    Test-Driven Development (TDD) is a methodology that helps you to write as little as code as possible to satisfy software requirements, and ensures that what you've written does what it's supposed to ...

    Test-Driven Development with Python 【第二版】

    Test-Driven Development with Python, 2nd Edition English | 2017 | ISBN-10: 1491958707 | 592 pages | PDF,MOBI,EPUB (conv) | 8.59 Mb By taking you through the development of a real web application from...

    Test-Driven Development with Python [2017]

    Test-Driven Development with Python: Obey the Testing Goat: Using Django, Selenium, and JavaScript by Harry J. W. Percival English | 2 Aug. 2017 | ISBN: 1491958707 | ASIN: B074HXXXLS | 604 Pages | AZW...

    Test-Driven Java Development(PACKT,2015)

    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 ...

    test driven development by example

    《测试驱动开发示例》是由Kent Beck撰写的一本关于TDD(Test-Driven Development,测试驱动开发)的经典书籍。本书特别适合Java开发人员阅读,它不仅介绍了TDD的基本概念和实践方法,还通过实际案例,一步步带领读者...

    Test-Driven Development(TDD).pptx

    Test-Driven Development(TDD)简介,使用Nunit开发自动测试案例.

Global site tag (gtag.js) - Google Analytics