Zeus : Running Test::Unit tests made easy

28 Dec 2013

In Rails 3.2, there are predefined tasks to run Test::Unit tests like rake test:units, rake test:functionals etc. But when you are developing, you may need to run a single test or tests from a file. None of the rake tasks provide this in Rails 3.2.

I like to show you how you can do this with zeus.

What’s this zeus?

Zeus is rails application preloader. It preload your rails environment so that you run rake tasks, server and console with in 1-2 seconds. It reloads itself when ever you make any changes to initializers or do a bundle. It will saves you from rails booting.

zeus test is coupled with some handy hacks which will let you run your tests easily. You can run all tests in a file or a single test.

Run tests in a single file

You can run tests from a single file by just passing the file path to zeus test

zeus test test/functional/some_test.rb

Run a single test

Consider this as your test case.

# test/functional/some_controller_test.rb
class SomeControllerTest < ActionController::TestCase
  def setup


  test 'should create' do
    # your test

Think that in the above case you need to run only should create. With zeus there are multiple ways to run single test.


You can use pass the test case as underscored and prepend with test_ which makes test_should_create and pass to -n option.

zeus test test/functional/some_controller_test.rb -n test_should_create


Another similar method is passing the test case in double quotes to -n option. Don’t forget to prepend test before test case.

zeus test test/functional/some_controller_test.rb -n "test should create"


The third method felt more comfortable for me. Just append :<line_no of test case> to the file path.

zeus test test/functional/some_controller_test.rb:7

Here 7 is the line number of test "should create".

In Rails 4, you can pass the filename to the rake tasks and Rails 4.1 will ship with spring preloader. But still I believe zeus will be my favorite to run tests.

Happy testing.

If you particularly enjoy my work, I appreciate donations given with Gittip.