向现有 Rails 项目添加测试的最佳策略是什么?

发布于 2024-11-02 01:52:41 字数 278 浏览 5 评论 0原文

有一个现有项目已部署在生产中。我们想要对其添加一些测试(越早越好),我必须在 BDD 方式(rspec/cucumber)或 TDD 方式(TestUnit)之间进行选择。我确实是从 BDD 开始的,我想知道最好的决定是什么?我担心在现有的 Rails 项目(本周部署并需要非常快的迭代)上使用 rspec/cucumber 将很难做到(特别是它不应该以这种方式使用,我的意思是我们应该首先编写故事/功能,然后从那里迭代)。

TestUnit 可能会更合理。

您对此有什么想法吗?有经验可以分享吗?一些建议?

There is an existing project that is already deployed in production. We want to add some tests on it (the sooner the better) and I have to choose between going the BDD way (rspec/cucumber) or the TDD way (TestUnit). I am really starting with BDD and I am wondering what could be the best decision to take? I am affraid that using rspec/cucumber on an existing rails project (which was deployed this week and requires really fast iterations) will be quite hard to do (especially that it is not supposed to be used this way, I mean we are supposed to write stories/features first and iterate from there).

TestUnit could be more reasonable, may be.

Do you have any thoughts on that? An experience to share? Some advices?

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

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

发布评论

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

评论(1

七婞 2024-11-09 01:52:41

我相信覆盖现有应用程序的最简单方法是使用 Cucumber。这将允许描述和记录网站/应用程序应该如何工作(并将继续工作)。

因为它是从外向内工作的,所以这还有一个优点,你不需要完全理解内部工作原理。同时,您可以在一次测试中测试应用程序的所有层(模型-视图-控制器)。

当您开始实际更改代码时,我将开始使用您最喜欢的测试框架为您正在更改的代码添加单元测试。我个人更喜欢 rspec,但正如你所知,这是个人选择:)

I believe the easiest way to get coverage for an existing application is to use cucumber. This will allow to describe and document how to the website/application should work (and will keep working).

Because it works from the outside in, this also has the advantage you do not need to comprehend the inner workings completely yet. At the same time, you test all layers of the application (model-view-controller) in one test.

When you start actually changing code, then I would start adding the unit-tests for the code you are changing, using your favourite testing framework. I personally favour rspec, but as you know this is a personal choice :)

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