continue execution when TEST::UNIT assertion fails

A

aidy

Hi,

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

cheers

aidy
 
T

Tim Pease

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
 
T

Tim Pease

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 )

Sorry, that should be a block

continue_test {assert false}

TwP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top