TDD和BDD的差异 [英] TDD and BDD Differences

查看:116
本文介绍了TDD和BDD的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

老实说,我看不到BDD和TDD之间的区别.我的意思是,这两个都是测试,如果发生了预期的情况.我见过充实的BDD测试,它们实际上可以算作TDD测试,而且我见过的TDD测试含糊不清,以至于它们将很多代码都装在了黑盒中.可以说,我非常相信两者都更好.

I honestly don't see the difference between BDD and TDD. I mean, both are just tests if what is expected happens. I've seen BDD Tests that are so fleshed out they practically count as TDD tests, and I've seen TDD tests that are so vague that they black box a lot of code. Let's just say I'm pretty convinced that having both is better.

这是一个有趣的问题.我从哪里开始?我从高水平的BDD测试开始吗?我从低级TDD测试开始吗?

Here's a fun question though. Where do I start? Do I start out with high level BDD tests? Do I start out with low level TDD tests?

推荐答案

老实说,我看不到BDD和TDD之间的区别.

I honestly don't see the difference between BDD and TDD.

那是因为没有.

我的意思是,两者都只是测试是否发生了预期的事情.

I mean, both are just tests if what is expected happens.

错了. BDD和TDD与测试绝对无关.没有.娜达齐尔奇压缩.尼克斯丝毫没有.

That's wrong. BDD and TDD have absolutely nothing whatsoever to do with testing. None. Nada. Zilch. Zip. Nix. Not in the slightest.

不幸的是,TDD在几乎所有内容中都带有"test"一词(不仅在名称上,而且在测试框架,单元测试,TestCase(通常从其继承的类),FooTest(该类)中通常包含您的测试),testBar(一种测试方法的典型命名模式),以及很多与测试相关的术语,例如断言"和验证"),这使某些人认为它实际上是确实与测试有关.因此,一些聪明的人说:嘿,让我们改名吧",以消除可能造成的混乱.

Unfortunately, TDD has the word "test" in pretty much everything (not only in its name, but also in test framework, unit test, TestCase (the class you tpyically inherit from), FooTest (the class which typically holds your tests), testBar (the typical naming pattern for a test method), plus a lot test-related terminology such as "assertion" and "verification") which leads some people to believe that it actually does have something to do with tests. So, some smart people said: "Hey, let's just change the name" to remove any potential for confusion.

这就是BDD.这只是TDD,所有与测试相关的术语都被与行为相关的示例术语所取代:

And that's what BDD is. It's just TDD with any test-related terminology replaced by examples-of-behavior-related terminology:

  • 测试→例子
  • 断言→期望
  • assertshould
  • 单位→行为
  • 验证→规格
  • …等等
  • Test → Example
  • Assertion → Expectation
  • assertshould
  • Unit → Behavior
  • Verification → Specification
  • … and so on

BDD只是带有不同单词的TDD.如果您正确执行TDD,那么您正在执行BDD.区别在于前提是您至少相信Sapir-Whorf假说的弱势形式.不同的词使正确做起来更容易.

BDD is just TDD with different words. If you do TDD right, you are doing BDD. The difference is that – provided you believe at least in the weak form of the Sapir-Whorf Hypothesis – the different words make it easier to do it right.

这篇关于TDD和BDD的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆