• [设计原则与模式] 如何理解TDD的三条规则


    cp from  :  https://blog.csdn.net/ibelieve1974/article/details/54948031 

    如何理解Bob大叔的TDD三条规则?
    第一条和第三条讲的是只有和只要。只有Case False的情况下才能写Code。只要新写的Code使得Case通过了,就不要写任何新功能代码了。重构是可以的。
    第二条是说只允许编写Case失败的代码。这一条操作起来有个疑惑。比如为写一个算法,先把写一个验证功能的Case,然后写代码。Case通过以后,想验证下特殊值情况,又写一个Case,结果Case也幸运的Pass了。这算不算违反了Bob大叔的TDD规则2呢? 经过咨询了James Grenning,这样做是可以的。第二条只允许编写失败Case是指对于未实现的新的功能。比如原计划写5个测试功能的Case,当你完成功能1和2开发和测试,那你就对未实现的功能3的写的测试case当然是fail的。但这不妨碍你继续写增加对功能1和2测试的验证case。

    You are not allowed to write any production code unless it is to make a failing unit test pass.
    1、除非为了使一个失败的unit test通过,否则不允许编写任何产品代码
    You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
    2.在一个单元测试中只允许编写刚好能够导致失败的内容(编译错误也算失败)
    You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
    3、只允许编写刚好能够使一个失败的unit test通过的产品代码


    ---------------------
    作者:Sleeping-Cat
    来源:CSDN
    原文:https://blog.csdn.net/ibelieve1974/article/details/54948031
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    成功连上数据库顿感世界美好许多
    MySQL数据库基本命令
    杭电1004 Let the Balloon Rise
    大数学习笔记
    安卓传感器开发之指南针
    java Class文件内部结构解析
    mysq数据库实战小型管理系统
    JSplitPane分隔线的用法
    swing 菜单+右键菜单+二级菜单实现
    input type=file 上传文件,同一个文件第二次上传无反应
  • 原文地址:https://www.cnblogs.com/0616--ataozhijia/p/11079644.html
Copyright © 2020-2023  润新知