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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top