From: Louis J Scoras Date: 2007-02-16T05:33:42+09:00 Subject: Re: Best way to skip tests Dan; How about something like this? Syntax could probably be cleaned up a bit: class Test::Unit::TestCase def self.skip_tests(opts, &tests) if opts[:if].call module_eval &tests else $stderr.puts "** #{opts[:msg]} -- skipped **" end end end Then you can just call it to skip your tests. class TC_Foo < Test::Unit::TestCase def test_everywhere assert true end module Foo Bar = 42 end skip_tests( :if => lambda { ENV['WINDOZE'] }, :msg => "Ballmer eats babies =)" ) do def test_bar assert_equal(42, Foo::Bar) end end end $ ruby t.rb Loaded suite t Started .. Finished in 0.001932 seconds. 2 tests, 2 assertions, 0 failures, 0 errors -------------------------------------------------- $ WINDOZE=1 ruby t.rb ** Ballmer eats babies =) -- skipped ** Loaded suite t Started . Finished in 0.001482 seconds. 1 tests, 1 assertions, 0 failures, 0 errors -- Lou.