【发布时间】:2016-07-13 13:15:13
【问题描述】:
在 Rails 中,我可以在测试中使用 test 关键字,我发现它非常有吸引力,并且是 Rspec 冗长的更好选择。
例子:
class TestMyClass < ActionController::TestCase
test 'one equals one' do
assert 1 == 1
end
end
目前我正在创建一个 gem,我想在我的测试中采用相同的方法 - 使用 test 方法。我尝试从 Minitest 和 UnitTest 继承,后者似乎有效。但是我的印象是 Rails 使用 Minitest。那么Minitest 是否真的提供了test 指令?
这行得通:
class TestMyClass < Test::Unit::TestCase
test 'one equals one' do
assert 1 == 1
end
end
这给了我“错误数量的测试参数”:
class TestMyClass < Minitest:Test
test 'one equals one' do
assert 1 == 1
end
end
【问题讨论】:
标签: ruby unit-testing minitest testunit