# manual way
Minitest.run(args)
# magic way
require 'minitest/autorun'
# or
Minitest.autorun
# Minitest 4
def self.autorun
at_exit {
exit_code = nil
at_exit {
@@after_tests.reverse_each(&:call)
exit false if exit_code && exit_code != 0
}
exit_code = MiniTest::Unit.new.run ARGV
} unless @@installed_at_exit
@@installed_at_exit = true
end
# Minitest 5
def self.autorun
at_exit {
next if $! and not $!.kind_of? SystemExit
exit_code = nil
at_exit {
@@after_run.reverse_each(&:call)
exit exit_code || false
}
exit_code = Minitest.run ARGV
} unless @@installed_at_exit
@@installed_at_exit = true
end