测试驱动开发与测试驱动设计相同吗?

发布于 2024-12-06 10:13:57 字数 97 浏览 0 评论 0原文

我开始学习测试驱动开发。我读过很多讨论 TDD 的文章。有些人将其称为测试驱动开发。其他人称之为测试驱动设计。它们是同一件事吗?我的印象是它们是相同的,但如果不是,主要区别是什么?

I'm starting to learn about Test Driven Development. I've read quite a few articles that talk about TDD. Some refer to it as Test Driven Development. Others call it Test Driven Design. Are they the same thing? I get the impression they are the same, but if not, what are the main differences?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

來不及說愛妳 2024-12-13 10:13:57

测试驱动开发是指描述如何编写代码的实践。

测试驱动设计还提出了一个额外的要求:遵循这种实践将产生良好的(整体)设计。

Test driven development refers to a practice describing how to write code.

Test driven design makes an additional claim: that following this practice will result in good (overall) design.

风轻花落早 2024-12-13 10:13:57

有一些 TDD 传播者主张“测试驱动开发”主要是一种设计技术,因此不久前他们将其重命名为“测试驱动设计”。但这种观点被其他人认为非常怀疑,例如阅读这篇前SO帖子

测试驱动开发是否将焦点从设计中转移出来?

Ralf Westphal 的一篇有趣的德国博客文章讨论了这个主题:

http://ralfw.blogspot.com/2011/07/test-driven-了解.html

(这是谷歌翻译 如果您不懂德语)。

There are some of the TDD evangelists adocating that "Test Driven Development" is primarily a design technique, so they renamed it "Test Driven Design" some time ago. But this point of view has been seen very sceptical by others, read for example this former SO post

Does Test Driven Development take the focus from Design?

There is also an interesting german blog entry of Ralf Westphal discussing this topic:

http://ralfw.blogspot.com/2011/07/test-driven-unterstanding.html

(Here's a Google Translation if you don't understand German).

落日海湾 2024-12-13 10:13:57

测试驱动开发是在编写生产代码之前开发测试。这背后的目标是产生所谓的“可执行需求”,而这一切都是为了编写足够的代码来满足需求。

如果您使用像 Moq 这样的 Mocking 框架,您将被迫使用依赖注入基于控制反转原则构建代码,这被认为是很好的实践,因为它减少了代码的“脆弱性”并促进了细粒度的松散耦合。您的解决方案的一个方面。

因此,回答你的问题 TDDevelopment 更多的是关于使用你想要的任何工具在代码中实现需求。 TDDesign 是单元测试发展的下一步,您可以通过采用 Moq 等 Mocking 框架来强制进行良好的设计。使用 TDDesign 生成的代码保证符合 IoC 容器(例如 spring)的要求。

TDDev 很好……TDDesign 更好。

Test driven development is developing tests before writing what will be the production code. The goal behind this is to produce what are called "executable requirements" and it is all about writing just enough code to satisfy requirements.

If you use a Mocking framework like Moq you will be forced to construct your code based on Inversion of Control principles, using Dependency Injection, which is considered good practice as it reduces the "brittleness" of your code and promotes loose coupling at a fine grained aspect of your solution.

So to answer your question TDDevelopment is more about implementing requirements in code, using whatever tools you wish. TDDesign is the next step in the evolution of unit testing where you force good design by adopting Mocking frameworks such as Moq. Code that is produced with TDDesign is guaranteed to conform to the requirements of an IoC container such as spring.

TDDev is good ... TDDesign is better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文