I’m moving my tests to the new ruby minitest library, and I am looking for the class that corresponds to the old Test::Unit::TestSuite class. All the examples I’ve found online show single test cases, but I’ve got:
require 'minitest/unit/testsuite'
require 'minitest/unit/ui/console/testrunner'
require 'tests/fs_session_test'
require 'tests/resource_test'
require 'tests/rest_session_test'
require 'tests/server_test'
class AllTests
def self.suite
suite = Test::Unit::TestSuite.new
suite << FSSessionTest.suite
suite << ResourceTest.suite
suite << RESTSessionTest.suite
suite << ServerTest.suite
end
end
Test::Unit::UI::Console::TestRunner.run(AllTests)
and I keep getting a LoadError on the testsuite require.
There is no
Test::Unit::TestSuitein minitest. You have several options, assuming your tests look something like this:The vital part here is
require 'minitest/autorun'which usesat_exitto run all tests it can find, just before the enclosing script exits. I find this to be the easiest way for running my test suites.Run tests with Rake
For example, you can create a
RakefileusingRake::TestTaskwhich runs all the tests in yourtest/directory:Run the tests with
Require tests in a Ruby file
If you frequently only need certain tests, you can also write a test script, something like
You could also include
require 'minitest/autorun'at the top of this file to ensure, the tests are run, but i do this at the top of every test file, anyway. Run the suite withResult
Both methods give you the same output, for example something like
Because mintiest makes use of
at_exit, there is really no need to group the tests before you run them. You never get the output of only one test. Unless, of course you run a test on its own, for example with