规范/请求有什么用处?
我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这完全取决于您的需要和想要的。测试的目标是证明您的应用可以运行一次,而不是两次或更多次。
我亲自为模型和助手编写 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.