Why do I need to use minitest / autorun?

Why do I need minitest/autoruninstead test/unitto generate a 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 above code, proactive interpreter warning

Instead, you will need "minitest / autorun"

+4
source share
1 answer

An example of your code will be completed with the name of a NameError: uninitialized constant Minitest.

You have two options:

  • Use test/unitin combination with Test::Unit::TestCaseor
  • use require 'minitest/autorun'in combination with Minitest::Test.

test/unit is outdated and it is recommended to use minitest (MiniTest is faster and less).

, , , :

  • require "test/unit" require "minitest/autorun"
  • Test::Unit::TestCase with Minitest::Test
  • assert_nothing_raised ()
  • assert_raise assert_raises.
  • , .

require 'minitest' require 'minitest/autorun' - , . , (. minitest-a-test-suite-with-method-level-granularity)

+1

Source: https://habr.com/ru/post/1620402/


All Articles