加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

TDD第一原则

发布时间:2020-12-14 00:49:02 所属栏目:百科 来源:网络整理
导读:我不明白 TDD FIRST principle在下面的代码中是不是被遵守的. 这些是我关于FIRST原则的笔记: Fast : run (subset of) tests quickly (since you’ll be running them all the time) Independent : no tests depend on others,so can run any subset in any
我不明白 TDD FIRST principle在下面的代码中是不是被遵守的.

这些是我关于FIRST原则的笔记:

  • Fast: run (subset of) tests quickly (since you’ll be running them all the time)
  • Independent: no tests depend on others,so can run any subset in any order
  • Repeatable: run N times,get same result (to help isolate bugs and enable automation)
  • Self-checking: test can automatically detect if passed (no human checking of output)
  • Timely: written about the same time as code under test (with TDD,written first!)

测验问题:

Sally wants her website to have a special layout on the first Tuesday of every month. She has the following controller and test code:

06000

What FIRST principle is not being followed?

  1. Fast
  2. Independent
  3. Repeatable
  4. Self-checking
  5. Timely

我不知道哪个FIRST原则没有被遵守:

> Fast:代码似乎很快,因为它的测试没有什么复杂的.
>独立性:测试不依赖于其他测试.
>可重复:每次测试都会得到相同的结果. ‘special_index’如果是星期二,’index’如果不是星期二.
自检:测试可以自动检测是否通过.
>及时:代码和测试代码同时显示在这里.

因为测试代码是在控制器代码之后出现的,所以我选择了Timely的测验.但是我错了,回想起来,这不是一个好选择.我不知道在这里没有遵循哪个FIRST原则.

它不是可重复的,因为不是每天都是星期二:)如果你在星期一运行这个测试,你会得到一个结果,如果你在星期二运行一个不同的结果.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读