在Rails中使用Minitest [英] Using Minitest in Rails

查看:59
本文介绍了在Rails中使用Minitest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我读了很多关于Minitest的文章.我真的很喜欢超轻量级测试框架的想法.我决定在最近的项目中用rspec替换它,并且没有运气让它全部正常工作.我的问题是

Recently, I've read quite a few articles about Minitest. I really like the idea of a super lightweight test framework. I decided to replace rspec with it in a recent project and have had no luck getting it all to work. My problems are

a)在我的验收/集成测试中获得命名路由(rspec和test :: unit似乎会自动包含它们,但minitest却不行),
b)而且由于总体上没有采用rails,这让我感到不安(每个人似乎都在使用rspec,尽管它经常与gems/libraries一起使用).

a) getting named routes in my acceptance/integration tests (rspec and test::unit seem to automatically include them but no go with minitest),
b) and the overall lack of adoption in rails makes me uneasy (everyone seems to be using rspec though it's used more with gems/libraries).

当rspec在测试rails应用程序中具有主要优势时,是否值得使用minitest?

Is it worth using minitest when rspec has the main dominance with testing rails applications?

推荐答案

我是 minitest-的作者导轨.从您最初要求的时间到现在,情况已经发生了很大的变化.我的答案假设您使用的是minitest-rails.

I'm the author of minitest-rails. Things have changed a lot from the time you originally asked this to now. My answer assumes you're using minitest-rails.

如果您使用的是minitest-rails,那么它就可以工作了(现在).您可以使用生成器来创建这些测试,也可以自己编写它们.您可以在接受/集成测试中找到所有指定的路径.

If you are using minitest-rails this just works (now). You can use the generators to create these tests, or write them yourself. All the named routes are available in your acceptance/integration tests.

require "minitest_helper"

describe "Homepage Acceptance Test" do
  it "must load successfully" do
    get root_path
    assert_response :success
  end
end

采用

我认为随着我们与Rails 4的距离越来越近,我们将继续看到将Minitest与Rails一起使用的关注.

Adoption

I think we will continue to see increased attention on using Minitest with Rails as we get closer to Rails 4.

我认为现在从Minitest开始是完全值得的.目前,Minitest中正在进行大量活动.它也与最近对快速测试的关注很好地吻合.但这实际上取决于您的应用程序和团队动态.

I think starting with Minitest now is totally worth it. There is tremendous activity going on in Minitest right now. It aligns nicely with the recent focus on fast tests as well. But it really depends on your app and team dynamics.

这篇关于在Rails中使用Minitest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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