Here are some other suggestions:

1) Perhaps try adding messages to your asserts.  If you just want some
extra logging when failures occur, this may be all you need to do.
All the assert methods I've seen support this; just add the message as
the last arg you pass to the assert call.

The message will show up in the test results if the test fails (even
when using Test::Unit::Reporter; the message will be in the "type"
column for failed test methods).  And as you might expect, you can use
#{} to interpolate variables in the message (from what I've seen, at
least. :) ).  This is really useful if you want to have extra
descriptive text beyond "<nil> is not true" after failed asserts.  For
example:

assert($ie.link(:text, nameOfLink).exists?, "Link with text
'#{name_of_link}' was not found!")

2) Another cool technique that Bret suggested to the list a month or so ago:

See http://www.mail-archive.com/wtr-general@rubyforge.org/msg04849.html

- Add this method to your test class:

============================================
  def verify boolean, message = 'verify failed.'
    add_assertion
    add_failure message, caller unless boolean
  end
============================================

- Now call the verify method instead of assert, and your test will
continue executing even if the verification fails:

============================================
test_testMethodFoo
  result = verify($ie.link(:text, nameOfLink).exists?)
  puts "Test is still executing..."
  if !result
    do_some_extra_stuff()
  end
end
============================================

I may not be using that method in the intended fasion, but this
technique brings up a lot of possibilities, regardless.

Thanks
Bill


On 9/22/06, Luke <[EMAIL PROTECTED]> wrote:
> I answer myself I've done something like this:
>
> begin
> assert($ie.link(:text, 'name_of_link').exists?)
> rescue =>e
> #my extra code to do something when assert failed, then i return exception
> raise
> end
>
> now it seems to work, does anyone know better way?
>
> Luke
>
> _______________________________________________
> Wtr-general mailing list
> Wtr-general@rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
>
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to