Minitest 5 update

Josef Stribny jstribny at redhat.com
Fri Mar 21 12:11:56 UTC 2014


Hi Rubyists,

as you have probably noticed we would like to update Rails framework to the latest version (4.1) when it's released[1].
The biggest task for us in this change is the update of Minitest to version 5. This would require test suites
of many gems that depends on Minitest to be fixed.

Here are the most significant changes of Minitest 5 taken from the changelog[2]:

* 12 major (oft incompatible) changes:

  * Renamed MiniTest to Minitest. Your pinkies will thank me. (aliased to MiniTest)
  * Removed MiniTest::Unit entirely. No more manager objects.
  * Added Minitest::Runnable. Everything minitest can run subclasses this.
  * Renamed MiniTest::Unit::TestCase to Minitest::Test (subclassing Runnable).
  * Added Minitest::Benchmark.
    * Your benchmarks need to move to their own subclass.
    * Benchmarks using the spec DSL have to have "Bench" somewhere in their describe.
  * MiniTest::Unit.after_tests moved to Minitest.after_tests
  * MiniTest::Unit.autorun is now Minitest.autorun. Just require minitest/autorun pls.
  * Removed ParallelEach#grep since it isn't used anywhere.
  * Renamed Runnable#__name__ to Runnable#name (but uses @NAME internally).
  * Runnable#run needs to return self. Allows for swapping of results as needed.

That means the minimal changes needed to be done for every minitest test suite include:

* rename MiniTest::Unit::TestCase to Minitest::Test
* change require 'minitest/unit' (or 'test/unit') to require 'minitest/autorun'
* delete MiniTest::Unit.autorun (or use Minitest.autorun)

For some really simple test suites that might be enough. Look at the changes done in Rails 4.1[3]
or in my own little gem[4] for how the necessary changes may look like. For the others some additional
changes might be required.

Another problem are gems that depends on Gem::TestCase (like RubyGems plugins)
since Gem::TestCase is inherited from MiniTest::Unit::TestCase. I guess this can't be easily
solved at the moment, but we probably don't have many gems like that, or are we?

So what do you think of this change? Should we address it by updating upstream test suites?
Do you know about other issues that this can cause and I forgot to mention?

Josef

[1] https://fedoraproject.org/wiki/Changes/Ruby_on_Rails_4.1
[2] https://github.com/seattlerb/minitest/blob/master/History.txt#L137
[3] https://github.com/rails/rails/commit/3073c531983de243219fb55be93fbcebfdd9c44e
[4] https://github.com/strzibny/ruby-ares/commit/a1017ce59eeb8bfb5256b6e7789d957ac4efc227



More information about the ruby-sig mailing list