Class: Test::Unit::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/assay/adapter/testunit.rb

Overview

:nodoc:

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)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/assay/adapter/testunit.rb', line 7

def run(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