Why do i require minitest/autorun instead of test/unit for generating unit test
require 'test/unit'
class Brokened
def uh_oh
"I needs fixing"
end
end
class BrokenedTest < Minitest::Test
def test_uh_of
actual = Brokened.new
assert_equal("I'm all better now", actual.uh_oh)
end
end
Running the above code, interpreter raise warning
You should require 'minitest/autorun' instead
Your code example will end in a NameError: uninitialized constant Minitest.
You have two possibilities:
test/unit in combination with Test::Unit::TestCase orrequire 'minitest/autorun' in combination with Minitest::Test.test/unit is deprecated and it is recommended to use minitest (MiniTest is faster and smaller).
If you switch the test gem you must change perhaps some more things:
require "test/unit" with require "minitest/autorun"
Test::Unit::TestCase with with Minitest::Test
assert_nothing_raised (details)assert_raise becomes assert_raises.You may use require 'minitest' instead require 'minitest/autorun' - you will get no syntax error, but there is also no test execution. If you want to execute tests, you must call them on your own (see minitest-a-test-suite-with-method-level-granularity)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With