🕷 software projects

by ryan davis



autotest and much more


ZenTest provides 4 different tools: zentest, unit_diff, autotest, and multiruby.

ZenTest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. ZenTest only works with Ruby and Test::Unit. Nobody uses this tool anymore but it is the package namesake, so it stays.

unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong. Do note that minitest 2.2+ provides an enhanced assert_equal obviating the need for unit_diff

autotest is a continous testing facility meant to be used during development. As soon as you save a file, autotest will run the corresponding dependent tests.

multiruby runs anything you want on multiple versions of ruby. Great for compatibility checking! Use multiruby_setup to manage your installed versions.


  • Scans your ruby code and tests and generates missing methods for you.
  • Includes a very helpful filter for Test/Spec output called unit_diff.
  • Continually and intelligently test only those files you change with autotest.
  • Test against multiple versions with multiruby.
  • Includes a LinuxJournal article on testing with ZenTest written by Pat Eyler.


There are two strategeries intended for ZenTest: test conformance auditing and rapid XP.

For auditing, ZenTest provides an excellent means of finding methods that have slipped through the testing process. I’ve run it against my own software and found I missed a lot in a well tested package. Writing those tests found 4 bugs I had no idea existed.

ZenTest can also be used to evaluate generated code and execute your tests, allowing for very rapid development of both tests and implementation.

Autotest Tips

Setting up your project with a custom setup is easily done by creating a “.autotest” file in your project. Here is an example of adding some plugins, using minitest as your test library, and running rcov on full passes:

require 'autotest/restart'

Autotest.add_hook :initialize do |at|
  at.testlib = "minitest/autorun"

Autotest.add_hook :all_good do |at|
  system "rake rcov_info"
end if ENV['RCOV']

Do note, since minitest ships with ruby19, if you want to use the latest minitest gem you need to ensure that the gem activation occurs! To do this, add the gem activation and the proper require to a separate file (like “.minitest.rb” or even a test helper if you have one) and use that for your testlib instead:


gem "minitest"
require "minitest/autorun"


Autotest.add_hook :initialize do |at|
  at.testlib = ".minitest"

Get The Code

If you just want to use zentest, you can install it via RubyGems:
gem install zentest
Fork me on GitHub If you want to hack on zentest, clone it from GitHub:
git clone git://github.com/seattlerb/zentest

Latest Activity