Search code examples
ruby-on-railsminitest

Customize minitest messages


Is there a way to customize test reports. Currently I am getting this line at the end of each test:

3 tests, 0 assertions, 0 failures, 0 errors, 0 skips

I want to include test file name to this line.


Solution

  • Minitest has a verbose option that will show the test name and execution time for each test that's run. How you pass the -v flag to Minitest will vary depending on how you're running your tests. See http://chriskottom.com/blog/2014/12/command-line-flags-for-minitest-in-the-raw/ for a sample of verbose output.

    Another option would be using minitest-reporters with the SpecReporter by adding it to your Gemfile and putting this in your test helper:

    require "minitest/reporters"
    Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
    

    See https://github.com/kern/minitest-reporters for more info.