-
Notifications
You must be signed in to change notification settings - Fork 9
Tapout with Minitest 4
First, install the Minitest TAP-Y/J plugin, Minitap. Be sure to install version 0.4.x, which is designed to work with Minitest 4 series. In addition to minitap this will install tapout, ansi and json gems.
$ gem install minitap -v 0.4.1
Or, of course, add it to your Gemfile.
gem "minitap", "~> 0.4"
Second, add this bit of code to your test helper script:
require 'minitap'
MiniTest::Unit.runner = MiniTest::TapY.new
Now when you run your tests, TAP-Y will be the output. If you want to make the output selectable, one way to do it is to wrap the above in an environment variable condition, e.g.
if ENV['rpt'] != 'default'
require 'minitap'
MiniTest::Unit.runner = MiniTest::TapY.new
end
Now the fun part. To get any one of the cool tapout report formats, simply pipe the output to the tapout
command line tool with the report format name as an argument.
$ ruby test/example_test.rb | tapout progress
If you don't supply a report format name, the traditional dot
reporter will be used.
Use tapout --help
to get a list of available report formats.
You can use tapout
with Rake's test task as well, just be sure to use the -q
option to remove extraneous output.
$ rake -q test | tapout
Of course you probably want to pass the output to tapout automatically. Thankfully Rake's test task allows us to append to the command that runs the test using TESTOPTS
environment variable.
$ TESTOPTS="| tapout" rake -q test
Or in the task's definition itself using the options
setting:
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/test*.rb']
t.verbose = false
t.options = "| tapout"
end