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

用简单的术语解释TDD

发布时间:2020-12-14 04:48:12 所属栏目:百科 来源:网络整理
导读:当我遇到 this问题时,我正在浏览StackOverflow.在这里,作者提到了他/她的调试风格: I am wondering how to do debugging. At present the steps I follow is, I complete a large script, Comment everything but the portion I want to check Execute the
当我遇到 this问题时,我正在浏览StackOverflow.在这里,作者提到了他/她的调试风格:

I am wondering how to do debugging. At present the steps I follow is,

  • I complete a large script,
  • Comment everything but the portion I want to check
  • Execute the script

在其中一个答案中,另一个用户说提问者正在以错误的方式调试:

Your sequence seems entirely backwards to me. Here’s how I do it:

  1. I write a test for the functionality I want.
  2. I start writing the script,executing bits and verifying test results.
  3. I review what I’d done to document and publish.

我对编程很新,我遵循第一种做事方式.似乎第二种方式称为测试驱动开发,它似乎是一种非常低效的做事方式.

你能用更简单的方式解释TDD及其优点吗?

解决方法

I follow the first way of doing things.

许多其他人也是如此

… the second way … seems to be a very inefficient way of doing things.

所有新的和不同的东西似乎效率低下.习惯于其他人都错了,你是对的.

你的职业生涯的其余部分将充满这种感觉.每一件新事物似乎效率低下.并且总是效率低下.

Can you explain TDD and its merits in a simpler way?

是.

TDD更有效率,因为它更有效.

你必须做测试.您可以先写或最后编写测试.无论哪种方式,你必须写它们.

您可以“评论除我要检查的部分之外的所有内容”,并尝试以缓慢,无效的方式查找错误.它通常是无效的,因为 – 如果没有测试来推动您的开发 – 您可能会编写无用的代码或浪费时间.

或者您可以编写测试并编写以有效方式通过测试的最少代码.

(编辑:李大同)

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

    推荐文章
      热点阅读