微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

TDD第一原则

我不明白 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原则.

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

原文地址:https://www.jb51.cc/javaschema/281907.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐