Minitest + all the features you always wanted.
- Ctrl+c stops tests and prints failures
- pastable rerun snippet for failures (disabled/integrated on rails 5)
- multiple before & after blocks
before :allblocks- around blocks
around { |t| Dir.chdir(...) { t.call } } - red-green output (disabled/integrated on rails 5)
mtestexecutable to run by line number and by folder (disabled/integrated on rails 5)- full backtrace for errors and assertions with verbose (
-v) let!let_allexecute once for all tests in a class and it's subclassesorder_dependent!to make your tests run in given orderMaxitest.static_class_order = trueno longer sort tests class/sub-classes in random ordercontextfor more expressionpending { assert false }is skip when it fails, but fails when it passes- implicit subject via
require 'maxitest/implicit_subject' xitto skip test (also does not call setup or teardown)with_envto change environment variables during test runcapture_stdoutandcapture_stderrto capture stdout or stderr but not both (likecapture_iodoes)require 'maxitest/timeout'to make hanging tests fail afterMaxitest.timeoutsecondsrequire 'maxitest/threads'fail tests that leave extra threads runningrequire 'maxitest/global_must'(before autorun) disable deprecation on globalmust_*or global_expectations gem
gem install maxitestrequire "maxitest/autorun"
# ... normal minitest tests ...
describe MyClass do
describe "#my_method" do
it "passes" do
_(MyClass.new.my_method).must_equal 1
end
end
endpending "need to fix" doto show why something is pendingpending "need to fix", if: ENV["CI"] doto only skip on CI (if something is supposed to work locally)
Use during test: with_env FOO: "bar do ...
Use as around block: with_env FOO: "bar"
Use as alias for describe
describe "#my_method" do
context "with bad state" do
before { errors += 1 }
it "fails" # ...
end
endoutput = capture_stdout { puts 1 }
_(output).must_equal "1\n"If PR is not resolved,
disable Interrupt handling with ENV["MAXITEST_NO_INTERRUPT"] = "true" to avoid "stack level too deep" errors.
- everything vendored into 1 gem to avoid dependency madness
- tested via rspec to avoid messing up our own tests by accident
- fixes should go back to the original libraries
- restrictive minitest dependency so nothing breaks by accident
- ruby >=3.0
rake bundleto update all vendored gems
- running by line number from minitest-line
- around from minitest-around
- mtest from testrbl
- red-green from minitest-rg
Michael Grosser
michael@grosser.it
License: MIT
