时分驱动? BD?我很困惑!我应该使用什么来进行测试以及为什么?
所以是的,我正在开始这个测试!
但我不知道该用什么=/
Rspec + Shoulda?
Rspec + 牛排?
迷你测试?
黄瓜?
水豚?
可以吗? (黄瓜与Shoulda混合)
迷你_应该吗? (Minitest with Shoulda mixup)
啊,这么多选择!我很困惑<.<我确实知道我想要一些小而简单的东西来测试我未来的 gems 和 sinatra & 。轨道应用程序。 你们使用什么以及为什么?
So yeah, I'm gettin' into this testing thing!
But I don't know what to use =/
Rspec + Shoulda?
Rspec + Steak?
Minitest?
Cucumber?
Capybara?
Coulda? (Cucumber with Shoulda mixup)
Mini_shoulda? (Minitest with Shoulda mixup)
Argh, so many choices! I'm confused <.< I do know I want something small and simple to test my future gems and sinatra & rails apps. What do you people use and why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您刚刚开始,您应该使用默认值并遵循官方指南。重要的是您练习测试。您使用哪个测试库/框架并不那么重要 - 这是一种风格选择,首先是实际练习测试的次要 - 开始测试 Rails 应用程序的最简单方法是遵循“黄金法则”官方指南列出的“路径”。
一旦您更加熟悉了 Rails 应用程序的测试,您将能够更好地评估现有的选项。我个人喜欢 rspec 和 cucumber(目前 - 我可能决定改变我的偏好),但我只有在已经对测试有所了解并且对 Rails 有所了解之后才能够提出这个偏好。
If you are just starting out, you should go with the defaults and follow the official guides. The important thing is that you practice testing. It's less important which testing library/framework you use - that's a stylistic choice that's secondary to actually practicing testing in the first place - and the easiest way to get starting testing your Rails app is to follow the "Golden Path" that the official guides lay out.
Once you get more comfortable with testing your Rails app, you will be in a much better position to evaluate the options out there. I personally like rspec and cucumber (at the moment - I may decide to change my preference), but I was only able to come up with this preference after already being somewhat familiar with testing and after already being somewhat familiar with Rails.
我刚刚看到这篇博文< /a> 其中指出:
然后它继续问:“如果我们同意 BDD 很好,为什么我们不以更适合 BDD 的格式(即 Cucumber 测试格式)编写单元测试呢?”并将 rspec 单元测试与 Cucumber 中的单元测试进行比较。
I just came across this blog post which states:
It then goes on to ask: "if we agree that BDD is good, why don’t we write our unit tests in a format that is more amenable to BDD, that being the Cucumber format of tests?" and compares rspec unit tests against unit tests in Cucumber.
在工作中,我们使用非常标准的 RSpec 和 Cucumber 组合。我不知道他们是如何决定这个特定的组合的,当我开始为我们工作时它就已经存在了,所以没有必要改变。而且它是一个非常广泛使用的组合,因此通过 Google 等查找示例并不难。
对于我基于 1.9 的私人项目,我想从现在开始我将使用 Minitest。没有外部依赖项,一个简单的 BDD DSL(
需要“minitest/spec”
)和一些其他细节,例如随机化。这是一个很好的快速介绍:http://www.bootspring。 com/2010/09/22/minitest-rubys-test-framework/
At work we use the pretty standard RSpec and Cucumber combination. I don't know how they decided on this specific combination, it was already there when I started and worked for us, so there was no need to change. Also it's a quite widely use combination so finding examples with Google etc. isn't too hard.
For my 1.9 based private projects I think I will use Minitest from now on. No external dependencies, a simple BDD DSL (
require 'minitest/spec'
) and some other niceties like randomization. Here's a nice quick intro:http://www.bootspring.com/2010/09/22/minitest-rubys-test-framework/
对于刚开始使用的人,我建议仅使用 RSpec。它并不能完成所有事情,但它可以让您构建合理的单元和集成测试集。当您遇到 RSpec 轻松处理的限制时,请让这种需求引导您选择其他工具。
For someone just getting started I recommend just using RSpec. It doesn't do everything but it will allow you to build up reasonable sets of unit and integration tests. When you run into the limits of what RSpec handles easily then let that need guide you in choosing additional tools.
无法提供比正义更明智的东西,但在您忽略这种智慧之前:-) 请观看此视频(Cascadia 2011 ruby conf 的最小作者 Ryan Davis):
http://confreaks.net/videos/618-cascadiaruby2011-size-doesn-t-matter
幻灯片:http://www.zenspider.com/~ryan/presentations/CascadiaRubyConf_2011_-_Size_Doesn%27t_Matter .pdf
能够非常快速地运行所有测试是一件非常好的事情。
Can't offer anything more sensible than Justice, but before you ignore that wisdom :-) do check out this video (minitest author Ryan Davis at Cascadia 2011 ruby conf):
http://confreaks.net/videos/618-cascadiaruby2011-size-doesn-t-matter
slides: http://www.zenspider.com/~ryan/presentations/CascadiaRubyConf_2011_-_Size_Doesn%27t_Matter.pdf
Being able to run all your tests very quickly is a very good thing.