规范/请求有什么用处?

发布于 2024-09-28 20:28:40 字数 246 浏览 1 评论 0原文

我使用 RSpec 来测试我可爱的小网络应用程序。对于集成测试,我使用 Steak。当使用 Rails 生成器时(是的,我知道这不是执行 TDD 的 Zen 方式),spec/requests 中也会生成一些文件。正如链接文本所述,它与集成测试类似(但我找不到更多信息)。

当使用牛排和黄瓜之类的东西时,仍然建议使用这些请求规格吗?

I use RSpec to test my lovely little web app. For integration tests I use Steak. When using Rails generators (yep, I know that this is not the Zen way of doing TDD) there are also some files in spec/requests generated. As stated on link text it is something similiar to integration test (but I couldn't find much more info).

Are those request specs still recommended when using something like Steak and Cucumber?

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

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

发布评论

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

评论(1

你与清晨阳光 2024-10-05 20:28:40

这完全取决于您的需要和想要的。测试的目标是证明您的应用可以运行一次,而不是两次或更多次。

我亲自为模型和助手编写 rspec 测试。我使用黄瓜来测试我的视图和控制器是否按照我期望的方式工作。有了这个,我可以证明我的整个应用程序按照我的预期工作,所以不,我不使用 spec/requests

有时我确实使用 spec/requests 来测试 API,但您也可以使用 Cucumber 来做到这一点。

有些人不喜欢 BDD 方式的 Cucumber 工作方式,并坚持使用 spec/requests。归根结底,这都是品味问题。

It all depends on what you need and want. The goal of testing is to prove that your app works once, not twice or more times.

I personally write rspec tests for models and helpers. I use cucumber to test that my views and controllers are working the way I expect them to. With this I can prove that my entire app works as I expect it to, so no, I don't use spec/requests.

Occasionally I do use spec/requests to test APIs, but you can do that with cucumber as well.

Some don't like the BDD-way cucumber works and stick with spec/requests. In the end it's all a matter of taste.

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