Skip to content
This repository
Fetching contributors…


Cannot retrieve contributors at this time

file 129 lines (86 sloc) 4.446 kb

Guard::Test Build Status

Test::Unit guard allows to automatically & intelligently launch tests when files are modified or created.

If you have any questions/issues about Guard or Guard::Test, please join us on our Google group or on #guard (


  • Compatible with Test::Unit >= 2.2 and Minitest (Ruby 1.9).
  • Auto-detection of the turn gem (notification is still missing though).
  • Tested on Ruby 1.8.6, 1.8.7, 1.9.2, REE, Rubinius and JRuby.


Please be sure to have Guard installed before continue.

If you're using Bundler, add it to your Gemfile (inside the test group):

gem 'guard-test'

and run:

$ bundle install

or manually install the gem:

$ gem install guard-test

Add Guard definition to your Guardfile by running this command:

$ guard init test


Please read Guard usage doc.


Guard::Test can be adapted to any kind of projects.

Standard Ruby project

guard 'test' do
  watch(%r{lib/(.+)\.rb})      { |m| "test/#{m[1]}_test.rb" }
  watch('test/test_helper.rb') { "test" }

Ruby On Rails project

guard 'test' do
  watch(%r{app/models/(.+)\.rb})                     { |m| "test/unit/#{m[1]}_test.rb" }
  watch(%r{app/controllers/(.+)\.rb})                { |m| "test/functional/#{m[1]}_test.rb" }
  watch(%r{app/views/.+\.rb})                        { "test/integration" }
  watch(%r{lib/(.+)\.rb})                            { |m| "test/#{m[1]}_test.rb" }
  watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
  watch('test/test_helper.rb')                       { "test" }

Please read the Guard documentation for more info about the Guardfile DSL.


Guard::Test allows you to choose between two different runners (Guard::Test's runners are inherited from Test::Unit's console runner):

  • default: Display tests results as they happen, with different chars (green . for pass, red F for fail, purple E for error) and print failures/errors messages & backtraces when all the tests are finished. Obviously, this is the guard-test default.
  • fastfail: Display tests results as they happen and print failures/errors messages & backtraces immediately.

Available options:

:rvm            => ['1.8.7', '1.9.2'] # directly run your specs on multiple Rubies, default: nil
:bundler        => false              # don't use "bundle exec" to run the test command, default: true if a you have a Gemfile
:runner         => 'fastfail'         # default: 'default'
:cli            => "-v"               # pass arbitrary CLI arguments to the Ruby/Turn command that runs the tests, default: nil
:notification   => false              # don't display Growl (or Libnotify) notification after the specs are done running, default: true
:all_on_start   => false              # don't run all the tests at startup, default: true
:all_after_pass => false              # don't run all tests after changed tests pass, default: true
:keep_failed    => false              # keep failed tests until them pass, default: true

Note about the :notification option

If you don't want to use Growl or Libnotify with any of your guards, you can set a GUARD_NOTIFY environment variable to false. You can do it by adding the following statement in you .bashrc/.bash_profile/.zshrc:

export GUARD_NOTIFY=false


Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.


Guard::Test follows Semantic Versioning, both SemVer and SemVerTag.


Rémy Coutable



Many thanks to Thibaud Guillaume-Gentil for creating the excellent Guard gem.

Something went wrong with that request. Please try again.