xUnit 框架和 BDD 可以一起工作吗?

发布于 2024-11-09 08:15:24 字数 617 浏览 3 评论 0原文

我读过的一些资源.. 将 BDD 称为对“糟糕的 TDD”的回应。

  • 行为规范与验证。测试和实现之间没有不适当的密切关系
  • 在业务开发测试人员之间使用普遍/共享的语言
  • 术语强调“行为”而不是“测试”。因此,给定何时、背景、场景、示例与测试套件、装置和案例。
  • 实时规范

不确定我是否错过了更多好处..请参与。

鉴于大多数用户(可能是本地现象)在规范的创建/详细说明/澄清中进行“协作”,但没有对编辑/查看/执行/维护自动化版本感兴趣(当然他们希望软件满足所有规格):

xUnit(例如 NUnit)是否有任何方面阻止它从存在BDD 的好工具?

  • 根据规范进行编写是一项与工具无关的技能。
  • 无处不在的语言也是如此。只需要努力才能将其取出,
  • 请注意上述限制。假设我采用与 BDD Give-When-Then 风格一致的 xUnit 测试命名风格。
  • 我获取/创建一个工具,它使用上述命名约定从测试结果文件生成类似的“实时文档”。

有人可以在我定制的 BDD 地图上标记“Here be Dragons”吗?

Some of the resources I read.. refer to BDD as a response to 'Bad TDD'.

  • Specification of behavior vs Verification. No inappropriate intimacy between tests and implementation
  • Use of ubiquitous/shared language between business-development-testers
  • Terminology emphasizes 'behavior' over 'testing'. So Given-When-Then, Context, Scenario, Examples vs Test Suites, Fixtures and Cases.
  • Live specifications

Not sure if I've missed more benefits.. please pitch in.

Given that most users (maybe a local phenomenon) 'collaborate' in the creation/elaboration/clarification of the specifications but are not interested in editing/viewing/executing/maintaining the automated versions (of course they expect all the specs to be met by the software):

is there any aspect of xUnit (say NUnit for instance) that prevents it from being a good tool for BDD ?

  • Writing in terms of Specifications is a skill that is tool-agnostic.
  • Ditto for ubiquitous language. It just needs effort to get it out
  • Note the above mentioned constraint. Assume I adopt a xUnit test naming style that is aligned with the BDD Given-When-Then style.
  • I get/create a tool that uses the above naming convention to generate similar "live docs" from the test result files.

Can someone mark the "Here be dragons" on my customized BDD map...

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

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

发布评论

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

评论(1

白日梦 2024-11-16 08:15:24

那么,这是给你的龙。

  1. 无论使用什么语言,GUI 的自动化仍然很困难。
  2. 用业务可以理解的术语来表达基于代码的 DSL 更加困难。
  3. 编写 DSL 需要一点时间。

然而:

  1. 在代码中进行自动化往往会在出现问题时提供更快的反馈,并且更容易调试。将 xUnit 包含在您的构建中也更容易。
  2. 维护基于代码的 DSL 更容易。
  3. 弄清楚如何使用 JBehave 或 Cucumber 比编写 DSL 花费的时间要长得多。

需要注意的是,“对不良 TDD 的反应”可能指的是 BDD 的早期,当时我们在类级别而不是在系统或应用程序级别进行操作。

我提供了场景单元级行为,使用 NUnit 和 C# 中的 DSL 或 Moq 编写。对我有用。除非有明显的好处,否则不要选择自然语言工具。我对其中一项做出了广泛的贡献,因此我有权在不带偏见的情况下提出这一建议。

我希望我能为您提供+1以上的建议,以指出创建/阐述/澄清和编辑/查看/执行/维护之间的区别!

Here are the dragons for you, then.

  1. Automation of GUIs remains hard, no matter what language you do it in.
  2. It's harder to phrase a code-based DSL in terms that the business understand.
  3. It takes a little bit of time to write the DSL.

However:

  1. Doing the automation in code tends to provide faster feedback when things go wrong, and it's easier to debug it. It's also easier to include xUnit in your build.
  2. It's easier to maintain a code-based DSL.
  3. It takes far longer to work out how to use, say, JBehave or Cucumber, than it does to write the DSL.

As a note, the "reaction to bad TDD" is probably referring to BDD's early days, when we did it at a class level instead of at a system or application level.

I offer examples of both scenarios and unit-level behavior, written using NUnit and a DSL or Moq in C#. Works for me. Don't go for the natural-language tools unless there's clear benefit. I have extensively contributed to one of them, so feel authorised to make this recommendation without prejudice.

I wish I could give you more than +1 for calling out the difference between creation/elaboration/clarification and editing/viewing/executing/maintaining!

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