You can discard minitest/autorunand challenge Minitest.runusing your own test.
Example:
gem 'minitest'
require 'minitest'
class MyTest1 < MiniTest::Test
def test_add
puts "call %s.%s" % [self.class, __method__]
assert_equal(2, 1+1)
end
def test_subtract
puts "call %s.%s" % [self.class, __method__]
assert_equal(0, 1-1)
end
end
class MyTest2 < MiniTest::Test
def test_add
puts "call %s.%s" % [self.class, __method__]
assert_equal(2, 1+1)
end
def test_subtract
puts "call %s.%s" % [self.class, __method__]
assert_equal(1, 1-1)
end
end
Minitest.run(%w{-n /MyTest1.test_subtract|MyTest2.test_add/})
Result:
Run options: -n "/MyTest1.test_subtract|MyTest2.test_add/" --seed 57971
call MyTest2.test_add
.call MyTest1.test_subtract
.
Finished in 0.002313s, 864.6753 runs/s, 864.6753 assertions/s.
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
When calling the following test:
Minitest.run(%w{-n /MyTest1.test_subtract/})
puts '=================='
Minitest.run(%w{-n /MyTest2.test_add/})
then you get
Run options: -n /MyTest1.test_subtract/
call MyTest1.test_subtract
.
Finished in 0.001959s, 510.4812 runs/s, 510.4812 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
==================
Run options: -n /MyTest2.test_add/
call MyTest2.test_add
.
Finished in 0.000886s, 1128.0825 runs/s, 1128.0825 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
Minitest.runuses the same options that you use on the command line. This way you can use a parameter -nwith your choice, for example. /MyTest1.test_subtract|MyTest2.test_add/.
You can define different tasks or methods with different Minitest.run-definition to define your test packages.
Caution: A non-downloadable test file cannot contain require 'minitest/autorun'.