RSpec和Cucumber(RSpec故事) [英] RSpec vs Cucumber (RSpec stories)

查看:230
本文介绍了RSpec和Cucumber(RSpec故事)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该在什么时候使用Rails应用程序和Cucumber(以前的rspec-stories)?我知道如何工作和积极使用规格,当然。但它仍然感到奇怪,使用黄瓜。我目前的观点是,当你为客户端实现应用程序时,使用Cucumber很方便,并且不了解整个系统应该如何工作。

When should I use specs for Rails application and when Cucumber (former rspec-stories)? I know how both work and actively use specs, of course. But it still feels weird to use Cucumber. My current view on this, is that it's convenient to use Cucumber when you're implementing application for the client and do not understand how the whole system is supposed to work yet.

但是如果我正在做我自己的项目呢?在大多数时间,我知道系统的部分如何交互。我所需要做的就是编写一堆单元测试。当我需要Cucumber时,可能的情况是什么?

But what if I'm doing my own project? For most of the time, I know how the parts of the system interact. All I need to do is to write a bunch of unit-tests. What are the possible situations when I would need Cucumber then?

并且,作为相应的第二个问题:如果我写黄瓜的故事,我必须写规格吗?

And, as a corresponding second question: do I have to write specs if I write Cucumber stories? Wouldn't it be double-testing of the same thing?

推荐答案

如果你还没有,你可能需要检查out Dan North的精彩文章,故事中有什么?作为起点。

If you haven't already, you might want to check out Dan North's excellent article, What's in a Story? as a starting point.

我们有两个主要用途的Cucumber故事。首先,因为故事的形式是非常具体的,它有助于集中产品所有者的清晰的他想要的功能。这是对话的令牌使用故事,并且无论我们是否在代码中实现故事都将是有价值的。第二,当流程运作良好,我们在开始撰写功能之前就已经有完整的故事 我们开始撰写这个功能(更多的是我们努力的理想,而不是每日的现实)

We have two main uses for Cucumber stories. First, because the story form is very specific it helps focus the product owner's articulation of the features he wants built. This is the "token for a conversation" use of stories, and would be valuable whether or not we implemented the stories in code. Second, when the process is working well enough that we have complete stories before we begin writing the feature (more of an ideal that we strive for than a daily reality), you have your acceptance criteria spelled out clearly and you know exactly what and how much to build.

在我们的Rails工作中,Cucumber故事不能代替rspec单元测试。两者携手并进。在实践中,单元测试往往驱动模型和控制器的开发,故事倾向于推动视图的开发(我们不倾向于为我们的视图编写rspec),并提供一个良好的测试应用程序作为一个整体从

In our Rails work, Cucumber stories do not substitute for rspec unit tests. The two go hand in hand. In practice, the unit tests tend to drive development of the models and controllers, and the stories tend to drive development of the views (we tend not to write rspec for our views) and provide a good test of the application as a whole from the user's perspective.

如果你独自工作,沟通方面可能不是那么有趣,但是你从Cucumber获得的集成测试可能是。如果您利用 webrat ,编写黄瓜可以快速和无痛的许多您的基本功能。

If you're working solo, the communication aspect may not be that interesting to you, but the integration testing you get from Cucumber might be. If you take advantage of webrat, writing Cucumber can be fast and painless for a lot of your basic functionality.

这篇关于RSpec和Cucumber(RSpec故事)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆