[英]minitest, test::unit, and rails
I read somewhere that 'minitest' is the "new test::unit for ruby 1.9.2+".我在某处读到 'minitest' 是“新的 test::unit for ruby 1.9.2+”。
But ruby 1.9.3 seems to include both test::unit and minitest , is that true?但是Ruby 1.9.3似乎包括测试::单位和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 测试中,如Rails 测试指南中所述......诸如ActiveSupport::TestCase
、 ActionController::TestCase
,这些是使用Test::Unit
还是Minitest
?
In the rails guide, it shows examples with tests defined like this:在 rails 指南中,它显示了具有如下定义测试的示例:
test "should show post" do
get :show, :id => @post.id
assert_response :success
end
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.这句法, test string
,而不是定义与名称类似方法test_something
-在文档中的任何未提及Test::Unit
或MINITEST。 Where's that coming from?这是从哪里来的? Is Rails adding it, or is it actually a part of... whatever testing lib rails is using? Rails 是否添加了它,或者它实际上是...任何测试库 rails 使用的一部分?
PS: Please don't tell me "just use rspec". PS:请不要告诉我“只使用 rspec”。 I know about rspec.我知道 rspec。 I am trying to explore the stdlib alternatives, in the context of rails.我正在尝试在 rails 的上下文中探索 stdlib 替代方案。
There is a Test::Unit
"compatibility" module that comes with Minitest, so that you can (presumably) use your existing Test::Unit tests as-is. Minitest 附带了一个Test::Unit
“兼容性”模块,因此您可以(大概)按原样使用现有的 Test::Unit 测试。 This is probably the Test::Unit
module you are seeing.这可能是您看到的Test::Unit
模块。
As of rails 3.2.3, generator-created tests include rails/test_help
which includes test/unit
.从 rails 3.2.3 开始,生成器创建的测试包括rails/test_help
,其中包括test/unit
。
The test "something" do
syntax is a rails extension. test "something" do
语法是一个 rails 扩展。 It's defined in ActiveSupport::Testing::Declarative
, which is require
'd by rails/test_help
.它的定义中ActiveSupport::Testing::Declarative
,这是require
通过“d rails/test_help
。
This is perhaps a bit of a tangential response, but as to your rspec comment... You might want to take a look at minitest/spec
which provides spec flavor syntax in stdlib in 1.9.x.这可能有点minitest/spec
,但至于您的 rspec 评论......您可能想看看minitest/spec
,它在 1.9.x 中的 stdlib 中提供了规范风味语法。
http://bfts.rubyforge.org/minitest/MiniTest/Spec.html http://bfts.rubyforge.org/minitest/MiniTest/Spec.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.