Test and exceptions

B

brian.kejser

Hi

In the file testcase.rb that is part of the Test module why are only the
AssertionFailedError, StandardError and ScriptError exceptions caught?

Shouldn't snippet one (see below) be changed to snippet two (see below)?

Thanks

Snippet One:

begin
setup
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue StandardError, ScriptError
add_error($!)
end
end

Snippet Two:

begin
setup
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object
add_error($!)
end
end




Here's the run method that is part of the testcase class ....

def run(result)
yield(STARTED, name)
@_result = result
begin
setup
__send__(@method_name)
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object #StandardError, ScriptError
add_error($!)
ensure
begin
teardown
rescue AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Object #StandardError, ScriptError
add_error($!)
end
end
result.add_run
yield(FINISHED, name)
end
 
J

Jan Svitok

Hi

In the file testcase.rb that is part of the Test module why are only the
AssertionFailedError, StandardError and ScriptError exceptions caught?

Shouldn't snippet one (see below) be changed to snippet two (see below)?

This was discussed on ruby-core, topic "test/unit doesn't rescue a
Exception", but it seems it's not commited yet.

Good point anyway ;-)
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top