Today I Learned

hashrocket A Hashrocket project

Running A Single MiniTest Example

Consider the following MiniTest file:

# test_stuff.rb
require 'minitest/autorun'

class TestStuff < MiniTest::Unit::TestCase
  def test_first_thing
    assert_equal 4, (2 * 2)

  def test_second_thing
    assert_equal 9, (3 * 3)

If we want to run all the tests in this file, we can do so with:

$ ruby test_stuff.rb

But what if we want to run a specific test? We can target a single MiniTest example with the --name flag and the name of that example. We can do something like the following:

$ ruby test_stuff.rb --name test_second_thing


See More #ruby TILs
Looking for help? Each developer at Hashrocket has years of experience working with Ruby applications of all types and sizes. We're an active presence at Ruby conferences, have written some of the most popular gems, and have worked on many of the web's Ruby on Rails success stories. Contact us today to talk about your Ruby project.