Skip to content

Tapout with Minitest

7rans edited this page Apr 5, 2014 · 3 revisions

Tapout with Minitest

For Minitest 4 please see Tapout with Minitest 4.

If you are currently using Minitest, the test framework that ships with Ruby, then you are in luck. Getting started is easy as pie.

First, install the Minitest TAP-Y/J plugin, Minitap. This will install minitap, tapout, ansi and json gems.

$ gem install minitap

Or, of course, add it to your Gemfile.

    gem "minitap", "~> 0.5"

Don't forget to bundle install.

Then run your tests with the --tapy or --tapj option.

$ ruby -Ilib test/example_test.rb - --tapy

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 -Ilib test/example_test.rb - --tapy | 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.

Most likely your project will have more than one test file. A simple way to handle this is to add a test runner script to your project. In this file simply require all the other tests to be run. For example, we might create a test/runner.rb script containing:

test_files = Dir.glob(File.join(File.dirname(__FILE__), '*_test.rb'))
test_files.each{ |f| require f }

Then all the test can be run simply enough with:

  $ ruby test/runner.rb - --tapy | tapout progress

An alternative is to use Rake. See Tapout with Rake for more information.

Clone this wiki locally