于今夕之何夕,唯读书以自省

    <<  拾起单元测试,再次上路 | 首 页 | 测试方法命名基本规则和state-based testing  >>
  • 什么是好的unit test?

    2009-09-02

    Tag:

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://bearwhisper.blogbus.com/logs/45598389.html

    根据The Art of Unit Testing With Examples in .NET,好的unit test应该具备如下特点:

    • It should be automated and repeatable.
    • It should be easy to implement.
    • Once it’s written, it should remain for future use.
    • Anyone should be able to run it.
    • It should run at the push of a button.
    • It should run quickly.

    如果这还不够,请回答下列问题,足以判断一个测试是否是好的unit test:

    • Can I run and get results from a unit test I wrote two weeks or months or years ago?
    • Can any member of my team run and get the results from unit tests I wrote two months ago?
    • Can I run all the unit tests I’ve written in no more than a few minutes?
    • Can I run all the unit tests I’ve written at the push of a button?
    • Can I write a basic unit test in no more than a few minutes?

    有任何一个问题的回答是“no”,对不起,您的测试不是unit test,而是integration test,书中对于此类测试定义如下:

    Integration testing means testing two or more dependent software modules as a group.

    因此,unit test的定义如下:

    A unit test is an automated piece of code that invokes the method or class being tested and then checks some assumptions about the logical behavior of that method or class. A unit test is almost always written using a unit-testing framework. It can be written easily and runs quickly. It’s fully automated, trustworthy, readable, and maintainable.


    历史上的今天:

    拾起单元测试,再次上路 2009-09-02
    为什么要敏捷?数据告诉你。。。 2008-09-02
    8.用破折号表示中断,或一个很长的同位语,或是总结 2008-09-02

    随机文章:

    多几只眼睛盯着产品——保持项目节奏实践之四 2009-05-19
    我们马上会变得更快——项目经理应该小心的游戏之十五 2009-05-04
    我们不能说“不”——项目经理应该小心的游戏之十二 2009-04-28
    2009.4.21 博客阅读笔记——敏捷团队成员与主管之职责 2009-04-21
    软件项目管理的十条忠告 2009-03-15

    收藏到:Del.icio.us




    引用地址:
    发表于03:07:50 | 编辑 | 继续话题 | 转发 | 分享 0

搜索

最新日志

  • 基本规则5:不要用逗号连接两个独立从句
  • 基本规则4:在连词引导的独立从句前要使用逗号
  • 基本用法规则3:用逗号分隔插入语表达方式
  • 克服在公共会议上做演讲的障碍
  • 为测试,保护独立性——用stub来打破对象之间的依赖关系
  • 测试方法命名基本规则和state-based testing
  • 什么是好的unit test?
  • 拾起单元测试,再次上路
  • 分离需求与GUI设计——保持项目节奏实践之七
  • 通过用例、用户故事、角色和场景来定义需求——保持项目节奏实践之六
全部日志>>

最新评论

  • fiberglass mesh:good, Their primitive medica...
  • Aquoi:关于翻译辅助方面的具体细节只字未提啊。。。 比如TM和...
  • 老才:想了解文章的背景,跟《纵横周刊》有关系吗?...
  • DING:四海游龙的酸辣汤甚是好味 楼上B, 我觉得四海游...
  • DING:已经买到了吧? http://book.sina.co...
  • velo:实占
  • 草根网:好文,收藏至20ju.com
  • DING:好文章好博客好方法! 策略,战略⋯⋯确实对于普通员工是...
  • Dr.chucky:您的这个博蛮好玩的 要不要来连接个看看?不行的话 我也把...
  • Dr.chucky:您的这个博蛮好玩的 要不要来连接个看看?不行的话 我也把...
  • RSS 什么是RSS?
    用IM提醒我内容更新
    订阅到QQ邮箱
    订阅到鲜果阅读器
    订阅到Google阅读器
    订阅到抓虾阅读器
  • 《城客》第四期:创意之城
    博客大巴
    博客大巴使用指南
    博客大巴模板中心
    免费注册博客大巴
    一键博客搬家工具
    中文互动杂志城客
Copyright © 2002-2009 BlogBus.com, All Rights Reserved. 博客大巴 版权所有
博客大巴模板设计:book | 作者: dngpng