TDD 和 BDD 的区别 [英] TDD and BDD Differences

查看:29
本文介绍了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 几乎在所有事物中都有测试"这个词(不仅在它的名称中,而且在测试框架、单元测试、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:

  • 测试 →示例
  • 断言 →期待
  • assert应该
  • 单位→行为
  • 验证→规格
  • …等等

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天全站免登陆