minitest,test :: unit和rails [英] minitest, test::unit, and rails

查看:64
本文介绍了minitest,test :: unit和rails的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处读到最小"是新的test :: unit for ruby​​ 1.9.2+".

I read somewhere that 'minitest' is the "new test::unit for ruby 1.9.2+".

但是ruby 1.9.3似乎都包括两者 最小,是真的吗?

But ruby 1.9.3 seems to include both test::unit and minitest, is that true?

在默认的Rails测试中,如 Rails测试指南 ...中所述,例如ActiveSupport::TestCaseActionController::TestCase,这些是使用Test::Unit还是Minitest?

In the default rails testing, as outlined in the Rails testing guide.... things like ActiveSupport::TestCase, ActionController::TestCase, are these using Test::Unit or Minitest?

在rails指南中,显示了具有如下定义的测试的示例:

In the rails guide, it shows examples with tests defined like this:

test "should show post" do
  get :show, :id => @post.id
  assert_response :success
end

Test::Unit或Minitest的文档中未提及与定义诸如test_something之类名称的方法相对的语法test string.那是哪里来的? Rails是在添加它,还是实际上是...测试lib rails正在使用的一部分?

That syntax, test string, as opposed to defining methods with names like test_something -- isn't mentioned in the docs for either Test::Unit or Minitest. Where's that coming from? Is Rails adding it, or is it actually a part of... whatever testing lib rails is using?

PS:请不要告诉我仅使用rspec".我了解rspec.我正在Rails的背景下尝试探索stdlib的替代方案.

PS: Please don't tell me "just use rspec". I know about rspec. I am trying to explore the stdlib alternatives, in the context of rails.

推荐答案

Minitest附带了一个Test::Unit"compatibility"模块,因此您可以(大概)按原样使用现有的Test :: Unit测试.这可能是您正在看到的Test::Unit模块.

There is a Test::Unit "compatibility" module that comes with Minitest, so that you can (presumably) use your existing Test::Unit tests as-is. This is probably the Test::Unit module you are seeing.

从rails 3.2.3开始,生成器创建的测试包括rails/test_help,其中包括test/unit.

As of rails 3.2.3, generator-created tests include rails/test_help which includes test/unit.

test "something" do语法是Rails扩展.它是在ActiveSupport::Testing::Declarative中定义的,而ActiveSupport::Testing::Declarativerails/test_help的.

The test "something" do syntax is a rails extension. It's defined in ActiveSupport::Testing::Declarative, which is require'd by rails/test_help.

这篇关于minitest,test :: unit和rails的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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