时分驱动? BD?我很困惑!我应该使用什么来进行测试以及为什么?

发布于 2024-10-14 16:12:38 字数 286 浏览 3 评论 0原文

所以是的,我正在开始这个测试!
但我不知道该用什么=/

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 技术交流群。

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

发布评论

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

评论(5

黄昏下泛黄的笔记 2024-10-21 16:12:38

如果您刚刚开始,您应该使用默认值并遵循官方指南。重要的是您练习测试。您使用哪个测试库/框架并不那么重要 - 这是一种风格选择,首先是实际练习测试的次要 - 开始测试 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.

洋洋洒洒 2024-10-21 16:12:38

我刚刚看到这篇博文< /a> 其中指出:

在 Ruby 中测试的公认方法似乎是使用 Rspec 进行单元测试并使用 Cucumber 进行验收测试(更高级别的功能测试)。

然后它继续问:“如果我们同意 BDD 很好,为什么我们不以更适合 BDD 的格式(即 Cucumber 测试格式)编写单元测试呢?”并将 rspec 单元测试与 Cucumber 中的单元测试进行比较。

I just came across this blog post which states:

It seems that the accepted way to test in Ruby is to use Rspec for unit tests and to use Cucumber for acceptance tests (higher level functional testing).

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.

黯然 2024-10-21 16:12:38

在工作中,我们使用非常标准的 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/

数理化全能战士 2024-10-21 16:12:38

对于刚开始使用的人,我建议仅使用 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.

旧瑾黎汐 2024-10-21 16:12:38

无法提供比正义更明智的东西,但在您忽略这种智慧之前:-) 请观看此视频(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.

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