Project

General

Profile

Actions

Feature #4025

closed

Add Assertion class to Core

Added by trans (Thomas Sawyer) over 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:33058]

Description

=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

Actions #1

Updated by naruse (Yui NARUSE) over 13 years ago

  • Status changed from Open to Rejected

=begin
This feature needs at least consensus among test frame work authors.
And it needs more use cases.
Your proposal prevents to define Assertion class it inherits other than Exception class.
=end

Updated by trans (Thomas Sawyer) almost 13 years ago

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.

Actions

Also available in: Atom PDF

Like0
Like0Like0