Class: Test::Unit::TestCase

Inherits:
Object show all
Defined in:
lib/ae/adapters/testunit.rb

Overview

:nodoc:

Constant Summary collapse

PASSTHROUGH_EXCEPTIONS =

These exceptions are not caught by #run.

[NoMemoryError, SignalException, Interrupt, SystemExit]

Instance Method Summary collapse

Instance Method Details

#run(result) {|STARTED, name| ... } ⇒ Object

Runs the individual test method represented by this instance of the fixture, collecting statistics, failures and errors in result.

Yields:

  • (STARTED, name)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ae/adapters/testunit.rb', line 22

def run(result)
  $_test_unit_result = result
  yield(STARTED, name)
  @_result = result
  begin
    setup
    __send__(@method_name)
  rescue AssertionFailedError => e
    add_failure(e.message, e.backtrace)
  rescue Exception => e
    if e.respond_to?(:assertion?) && e.assertion?
      add_failure(e.message, e.backtrace)
    else
      raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
      add_error($!)
    end
  ensure
    begin
      teardown
    rescue AssertionFailedError => e
      add_failure(e.message, e.backtrace)
    rescue Exception => e
      if e.respond_to?(:assertion?) && e.assertion?
        add_failure(e.message, e.backtrace)
      else
        raise if PASSTHROUGH_EXCEPTIONS.include? $!.class
        add_error($!)
      end
    end
  end
  result.add_run
  yield(FINISHED, name)
end