是否可以将 BDD 包含到即将完成的项目中?

发布于 2024-12-21 14:56:11 字数 460 浏览 1 评论 0原文

我的软件公司以前从未做过 BDD 甚至 TDD。之前的测试意味着在部署前几天简单地尝试新软件。

我们最近的项目大约完成了 70%。我们还将其用作新技术、工具和开发方式的游乐场。我的老板希望我改用它来“测试测试”。

我尝试了 Selenium 2 和 RSpec。两者都很有前景,但如何赶上几个月的发展呢?进一步的问题是:

  • 新语言
  • 从来没有自己写过一行代码,
  • 很大一部分是由自由职业者编写的,
  • 大量花哨的黑客攻击,
  • 除了一些源代码注释和流程图之外,根本没有任何文档,

我所能做的就是用硒。这看起来相当痛苦(但仍然有可能),因为该软件显然从来没有打算以这种方式进行测试。我们有很多动态生成的 id、精美的 jQuery 等等。甚至不知道如何开始使用 RSpec。

那么,这个项目还可以应用BDD吗?还是应该逃得远远的,永远不再回来?

My software company never did BDD or even TDD before. Testing before meant to simply try out the new software some days before deployment.

Our recent project is about 70% done. We also use it as a playground for new technologies, tools and ways of developement. My boss wanted that I switch to it to "test testing".

I tried out Selenium 2 and RSpec. Both are promising, but how to catch up months of developement? Further problems are:

  • new language
  • never wrote a line of code by myself
  • huge parts are written by freelancer
  • lots of fancy hacking
  • no documentation at all besides some source comments and flow charts

All I was able to was to do was to cover a whole process with Selenium. This appeared to be quite painfully (but still possible), since the software was obivously never meant to be testet this way. We have lots of dynamically generated id ´s, fancy jQuery and much more. Dont even know how to get started with RSpec.

So, is it still possible to apply BDD to this project? Or should I run far away and never come back?

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

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

发布评论

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

评论(2

维持三分热 2024-12-28 14:56:11

在开始之前 - 您是否询问过老板他对测试的重视程度?我会先和你的老板澄清这一点。系统级 BDD 的主要好处在于在编写代码之前与业务利益相关者进行对话。如果您所做的只是包装现有代码,您将无法获得此结果。在单元级别,主要的好处是质疑类的责任及其行为,而这又是你无法得到的。不过,它可能有助于帮助您了解应用程序和每个级别的代码的价值。

如果您的老板只是想尝试 BDD 或 TDD,那么启动一个新项目可能会更简单,甚至可以从其他人那里获取现有项目来进行一些测试。如果他真的想在遗留代码上尝试 BDD,那么坚持使用你所拥有的可能是值得的 - @Esko 的书籍建议很不错。围绕现有功能进行更高级别的系统测试可以帮助您在重构较低级别的代码时避免破坏事情(如果您想进行测试,则需要这样做)。我还推荐Martin Fowler 的“重构”

RSpec 最适合在单元级别应用 BDD,作为 TDD 的变体。如果您希望在整个环境中进行自动化测试,请查看 Cucumber。它使重复使用步骤变得更加简单。然后,您可以直接从您的步骤调用 Selenium。

我在这里整理了关于BDD的一页链接,希望能帮助新人理解它更好的。祝你好运。

Before you start - have you asked your boss what he values from the testing? I'd clarify this with your boss first. The main benefits of system-level BDD are in the conversations with business stakeholders before the code is written. You won't be able to get this if all you're doing is wrapping existing code. At a unit level, the main benefits are in questioning the responsibilities of classes and their behavior, which, again, you won't be able to get. It might be useful for helping you understand the value of the application and each level of code, though.

If your boss just wants to try out BDD or TDD it may be simpler to start a new project, or even grab an existing project from someone else to wrap some tests around. If he genuinely wants to experiment with BDD over legacy code, then it may be worth persisting with what you have - @Esko's book suggestion rocks. Putting higher-level system tests around the existing functionality can help you to avoid breaking things when you refactor the lower-level code (and you will need to do so, if you want to put tests in place). I additionally recommend Martin Fowler's "Refactoring".

RSpec is best suited to applying BDD at a unit level, as a variant of TDD. If you're looking to wrap automated tests around your whole environment, take a look at Cucumber. It makes reusing steps a lot simpler. You can then call Selenium directly from your steps.

I put together a page of links on BDD here, which I hope will help newcomers to understand it better. Best of luck.

战皆罪 2024-12-28 14:56:11

阅读有效使用旧代码一书可能会有所帮助。还有一个 PDF 格式的简短版本

Reading the book Working Effectively with Legacy Code might be helpful. There is also a short version in PDF form.

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