Issue #4025 has been updated by Thomas Sawyer.


Pretty sure Assertion has to be subclass of Exception, because the way test runners work is to use #rescue to catch Assertion failure and other exceptions. Test framework developers can still subclass it for their own specific purposes, e.g. original TestUnit library could do:

    module Test
      module Unit
        class Failure < Assertion

An alternative is to define methods Exception#assertion? and Exception#set_assertion(boolean). Then test framework developers can use that to differentiate assertions from other errors.


----------------------------------------
Feature #4025: Add Assertion class to Core
http://redmine.ruby-lang.org/issues/4025

Author: Thomas Sawyer
Status: Rejected
Priority: Normal
Assignee: 
Category: 
Target version: 


=begin
 I notice every test framework has it's own Assertion class (names very such as AssertionFailure, AssertionFailureError, etc.)
 
 It would help interoperability if Ruby had a base exception they all could depend upon. Essentially:
 
   class Assertion < Exception; end
 
 This comes from MiniTest, just taken out of the MiniTest namespace.
 
 Having a common base class would allow developers to more easily write test utility libraries that could be used by a variety of test frameworks.
=end



-- 
http://redmine.ruby-lang.org