On Sun, 14 May 2006, Sy Ali wrote: > I played with 'ensure', but it wasn't the answer.. =) > > > On 5/13/06, Daniel Harple <dharple / generalconsumption.org> wrote: >> You can setup your test runner manually: > <snip> >> You could do the same with a suite. See the [Test::Unit docs][1] on >> how to create a test suite manually. > <snip> >> [1]: http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/ > > I'm looking into this next. I'm not using Rake, so I'll look at the > docs on test unit to do things more manually. > > >> Why exactly do you need this code to be run at the end of your test? > > I'm doing this because I have some tests which will be specific for a > platform, and I want to generate a report to state which tests were > skipped. > > Is there an easy way for me to abort a test? (i.e. to exit the test > method cleanly?) harp:~ > cat a.rb require 'test/unit' class FooBarTest < Test::Unit::TestCase def test_000 assert true end def test_001 assert true abort_test! assert false end def abort_test! throw 'abort_test!' end def self.abortable m m, m2 = "#{ m }", "__#{ m }__" alias_method m2, m define_method(m){|*a| catch('abort_test!'){ send(m2,*a) } } end instance_methods.each{|m| abortable m if m =~ %r/^test/} end harp:~ > ruby a.rb Loaded suite a Started .. Finished in 0.000518 seconds. 2 tests, 2 assertions, 0 failures, 0 errors regards. -a -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama