Better minitest output with turn gem.

This is a short post about using turn gem with MiniTest::Spec and Rails 3.1 for better output.

Add to your Gemfile:
group :test do
  gem 'turn'
end
Don't forget to run bundler against your new Gemfile content:
$ bundle install

Assuming you have this in your test file:
require "minitest_helper"
Add to your test/minitest_helper.rb:
Turn.config do |c|
 # use one of output formats:
 # :outline  - turn's original case/test outline mode [default]
 # :progress - indicates progress with progress bar
 # :dotted   - test/unit's traditional dot-progress mode
 # :pretty   - new pretty reporter
 # :marshal  - dump output as YAML (normal run mode only)
 # :cue      - interactive testing
 c.format  = :outline
 # turn on invoke/execute tracing, enable full backtrace
 c.trace   = true
 # use humanized test names (works only with :outline format)
 c.natural = true
end

Now, you can run your tests and enjoy chosen output format:
$ rake test

This post is based on some other sources. Please take a look at them to find more:

Comments

  1. Nice! Can I help out with reporter functionality?

    ReplyDelete
  2. Sure, you can. Whatever you mean;)

    ReplyDelete
  3. Hi , first thanks for your clear post..
    I tried to follow all you steps , it's running , BUT I got a very strange behavior :

    in my minitest_helper.rb , if I write c.trace = true , I don't get the trace ...
    if I write c.trace = false , I get the trace ...

    Gemfile
    group :test do
    gem 'minitest'
    gem 'turn'

    Rails (3.2.3) w Ruby 1.9.3-p125
    minitest (2.12.1)
    turn (0.9.5)

    ReplyDelete
  4. Thanks, useful post, but contains a bug, which is the cause of kadoudal's observation.

    "c.trace = true" causes the error `limit_backtrace': undefined method `to_i' for true:TrueClass (NoMethodError).

    It's possible that variable was previously boolean, but this should now be an integer declaring number of backtrace lines to show, e.g.:
    c.trace = 20

    ReplyDelete

Post a Comment