Reputation: 13487
I am following the codeschool course on testing with Ruby and they are using Test::Unit
. When I try to require test/unit
though it says the following:
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/test/unit.rb:3:in `<top (required)>'
test.rb:1:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
/
When I follow the instructions and require 'minitest/autorun'
, and then try to run my test it does not recognize the method assert_equal
test.rb:5:in `<main>': undefined method `assert_equal' for main:Object (NoMethodError)
So what is the deal with this? Does test/unit no longer exist? If that is the case, how do I run test with minitest? Does minitest use the same syntax or is it something different entirely?
Upvotes: 1
Views: 220
Reputation: 35443
Minitest is the new name for Test::Unit. It is fully compatible. Your syntax will still work for assert_equal
,
You do need to put the code into a test case.'
Example:
require "minitest/autorun"
class TestMe < Minitest::Test
def test_foo # test methods must begin with "test_"
assert_equal 1, 1
end
end
Upvotes: 4