Forum: Ruby continue execution when TEST::UNIT assertion fails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F09f7d15d9fefc2cf68c4057694c8930?d=identicon&s=25 aidy (Guest)
on 2007-04-16 18:11
(Received via mailing list)
Hi,

Is is possible not to halt the execution of a ruby script when an
TEST::UNIT assertion fails?

cheers

aidy
4d5b5dd4e263d780a5dfe7ac8b8ac98c?d=identicon&s=25 Tim Pease (Guest)
on 2007-04-16 20:32
(Received via mailing list)
On 4/16/07, aidy <aidy.rutter@gmail.com> wrote:
> Hi,
>
> Is is possible not to halt the execution of a ruby script when an
> TEST::UNIT assertion fails?
>

Yes, you can ...

begin
  assert false
rescue Test::Unit::AssertionFailedError => e
  self.send(:add_failure, e.message, e.backtrace)
end


Or if you would like a little method ...

def continue_test
  begin
    yield
  rescue Test::Unit::AssertionFailedError => e
    self.send(:add_failure, e.message, e.backtrace)
  end
end

continue_test( assert false )


Blessings,
TwP
4d5b5dd4e263d780a5dfe7ac8b8ac98c?d=identicon&s=25 Tim Pease (Guest)
on 2007-04-17 00:28
(Received via mailing list)
On 4/16/07, Tim Pease <tim.pease@gmail.com> wrote:
>   assert false
>   rescue Test::Unit::AssertionFailedError => e
>     self.send(:add_failure, e.message, e.backtrace)
>   end
> end
>
> continue_test( assert false )
>

Sorry, that should be a block

continue_test {assert false}

TwP
This topic is locked and can not be replied to.