ZenTest: May 2007 Archives

FozWorks: Validating Fixtures: Something I helped write with Jeremy for democracy now. I'll probably ship it soon... somewhere.

I just finished diagnosing a problem with two users who were both seeing the following stack trace when firing up autotest:

.../rubygems.rb:325:in `latest_partials':
    undefined method `[]' for nil:NilClass (NoMethodError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:322:in `each'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:322:in `latest_partials'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:292:in `latest_load_paths'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:291:in `each'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:291:in `latest_load_paths'
from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/lib/autotest.rb:109:in `
autodiscover'
from /usr/local/lib/ruby/gems/1.8/gems/ZenTest-3.6.0/bin/autotest:36
from /usr/local/bin/autotest:18:in `load'
from /usr/local/bin/autotest:18

It apparently turns out (ironically), that rspec 0.8 or so installed a bogus gem named "web_spec" with no version or anything and was choking the latest_load_paths method I was using in rubygems. This gem wasn't removed when you removed rspec so it might still be floating around in your system. If so, please remove it.

cd `gem env gem path`/gems
sudo rm -rf web_spec*
cd ../specs
sudo rm -rf web_spec*

autotest 3.6.0 and rspec

| | Comments (1)

According to David Chalimsky, when you upgrade to autotest 3.6.0 with rspec 1.0.3+, you'll need to run the following in your rails project:

  script/generate rspec

For non-rails projects, it should run fine out of the box.

ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails.

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.

unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong.

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!

Test::Rails helps you build industrial-strength Rails code.

Changes:

3.6.0 / 2007-05-25

  • 4 major enhancements:
    • New auto-discovery mechanism to make rspec and friends work independently!
    • Moved and restructured camping and rails as plugins.
    • Removed rspec - now packaged with rspec and/or as plugin.
    • Changed the way FTM tests are named. Allows multiple matricies.
  • 3 minor enhancements:
    • Added :OK special result value to FTM.
    • Hugh Sasse is awesome. Rdoc happiness.
    • Parameterized emacs client command.
  • 3 bug fixes:

    • Dup load path because I'm dum.
    • Fixed a lame syntax error in emacs.rb.
    • autotest now builds command separator with '&' on windoze. ARGH! Why is this the first I've heard of this?!?
  • http://www.zenspider.com/ZSS/Products/ZenTest/

  • http://rubyforge.org/projects/zentest/
  • ryand-ruby@zenspider.com

Dr Nic posts his video of my functional test matrix presentation at rejectconf. YAY!

I've been wanting to do something like this for a little while... Namely, I was getting tired of cryptic little codes for everything. Here and there I don't mind, but for every action I'd rather the nominal case fade into the background. So, like :na, I added :OK, which has the added benefit of rendering green instead of blue in emacs (because it is uppercase, I think ruby-mode thinks it is a const).

Before:

  matrix :pages,     :c_rw, :c_W,  :c_R,  :o_rw, :g_c,  :a_rw, :a_W, :a_R
  action :delete,    :del,  :del,  :del,  :del,  :e_NF, :del,  :del,  :del
  action :edit,      :edit, :edit, :edit, :edit, :e_NF, :edit, :edit, :edit
  action :publish,   :pub,  :pub,  :pub,  :pub,  :e_NF, :pub,  :pub,  :pub
  action :unpublish, :unpb, :unpb, :unpb, :unpb, :e_NF, :unpb, :unpb, :unpb
  action :update,    :updt, :updt, :updt, :updt, :e_NF, :updt, :updt, :updt
  action :view,      :view, :view, :view, :view, :e_NF, :view, :view, :view

After:

  matrix :pages,     :c_rw, :c_W, :c_R, :o_rw, :g_c,  :a_rw, :a_W,  :a_R
  action :delete,    :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :edit,      :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :publish,   :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :unpublish, :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :update,    :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :view,      :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK

See how nice all those error cases pop out at you now? I love that. Now I can gloss over the green OKs and question everything else (n/a's and errors alike). It'll help me question my requirements even more.

:OK dispatches to a validator with the same name as the action, so now they're more readable.

Before:

def matrix_test_unpub(...)
  # ...
end

After:

def matrix_test_unpublish(...)
  # ...
end

Absolutely fantastic:

The Poka-Yoke principle and how to write better software

Basic Tenents of Poka-Yoke Testing:

  • Unit Tests have to be as fast as lightning
  • Quick and slow tests should be separated
  • Tests must be reliable
  • Tests must be repeatable

This is the gist of what I try to teach coming on to any new project. Beautifully written. I'll have to steal some of the language simply because it gets the point across so well.

About this Archive

This page is a archive of entries in the ZenTest category from May 2007.

ZenTest: April 2007 is the previous archive.

ZenTest: June 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.1