class TestUnitFixture::TestTeardown

Public Instance Methods

called(id) click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 473
def called(id)
  called_ids << id
end
called_ids() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 469
def called_ids
  @called_ids ||= []
end
custom_teardown_method0() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 483
def custom_teardown_method0
  called(:custom_teardown_method0)
  raise "custom_teardown_method0"
end
custom_teardown_method1() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 494
def custom_teardown_method1
  called(:custom_teardown_method1)
  raise "custom_teardown_method1"
end
setup1() { || ... } click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 549
def setup1
  called(:setup1)
  begin
    yield
    called(:setup1_after_yield)
  ensure
    called(:setup1_teardown)
  end
end
setup2() { || ... } click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 560
def setup2
  called(:setup2)
  begin
    yield
    called(:setup2_after_yield)
  ensure
    called(:setup2_teardown)
  end
end
teardown() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 477
def teardown
  called(:teardown)
  raise "teardown"
end
test_nested() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 516
def test_nested
  called = []
  parent_test_case = Class.new(Test::Unit::TestCase) do
    teardown do
      called << :parent
    end
  end

  child_test_case = Class.new(parent_test_case) do
    teardown do
      called << :child
    end

    def test_nothing
    end
  end

  run_test_nothing(child_test_case)
  assert_equal([:child, :parent],
               called)
end
test_nothing() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 504
def test_nothing
end
test_setup_with_block() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 538
def test_setup_with_block
  test_case = Class.new(Test::Unit::TestCase) do
    def called_ids
      @called_ids ||= []
    end

    def called(id)
      called_ids << id
    end

    setup
    def setup1
      called(:setup1)
      begin
        yield
        called(:setup1_after_yield)
      ensure
        called(:setup1_teardown)
      end
    end

    setup
    def setup2
      called(:setup2)
      begin
        yield
        called(:setup2_after_yield)
      ensure
        called(:setup2_teardown)
      end
    end

    def teardown
      called(:teardown)
    end

    def test_nothing
      called(:test)
      flunk
      called(:test_after_failure)
    end
  end

  assert_called_fixtures([
                           :setup1,
                           :setup2,
                           :test,
                           :setup2_teardown,
                           :setup1_teardown,
                           :teardown,
                         ],
                         test_case)
end
test_with_after_option() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 426
def test_with_after_option
  expected_teardown_calls = [:teardown,
                             :custom_teardown_callback3,
                             :custom_teardown_method3,
                             :custom_teardown_method0,
                             :custom_teardown_callback0,
                             :custom_teardown_method1,
                             :custom_teardown_callback1]
  test_case = assert_teardown(expected_teardown_calls,
                              [[{:after => :append}],
                               [{:after => :append}],
                               [{:after => :prepend}],
                               [{:after => :prepend}]])
  assert_inherited_teardown(expected_teardown_calls, test_case)

  assert_inherited_teardown([:teardown], nil)
  assert_called_fixtures(expected_teardown_calls, test_case)
end
test_with_before_option() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 407
def test_with_before_option
  expected_teardown_calls = [:custom_teardown_callback3,
                             :custom_teardown_method3,
                             :custom_teardown_method0,
                             :custom_teardown_callback0,
                             :custom_teardown_method1,
                             :custom_teardown_callback1,
                             :teardown]
  test_case = assert_teardown(expected_teardown_calls,
                              [[{:before => :append}],
                               [{:before => :append}],
                               [{:before => :prepend}],
                               [{:before => :prepend}]])
  assert_inherited_teardown(expected_teardown_calls, test_case)

  assert_inherited_teardown([:teardown], nil)
  assert_called_fixtures(expected_teardown_calls, test_case)
end
test_with_exception() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 467
def test_with_exception
  test_case = Class.new(Test::Unit::TestCase) do
    def called_ids
      @called_ids ||= []
    end

    def called(id)
      called_ids << id
    end

    def teardown
      called(:teardown)
      raise "teardown"
    end

    teardown
    def custom_teardown_method0
      called(:custom_teardown_method0)
      raise "custom_teardown_method0"
    end

    teardown do
      called(:custom_teardown_callback0)
      raise "custom_teardown_callback0"
    end

    teardown
    def custom_teardown_method1
      called(:custom_teardown_method1)
      raise "custom_teardown_method1"
    end

    teardown do
      called(:custom_teardown_callback1)
      raise "custom_teardown_callback1"
    end

    def test_nothing
    end
  end

  assert_called_fixtures([:custom_teardown_callback1,
                          :custom_teardown_method1,
                          :custom_teardown_callback0,
                          :custom_teardown_method0,
                          :teardown],
                         test_case)
end
test_with_invalid_option() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 445
def test_with_invalid_option
  assert_invalid_teardown_option(:unknown => true)
  assert_invalid_teardown_option(:before => :unknown)
  assert_invalid_teardown_option(:after => :unknown)
end
test_with_option_to_inherited() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 451
def test_with_option_to_inherited
  expected_teardown_calls = [:teardown]
  test_case = assert_teardown(expected_teardown_calls, nil)
  assert_inherited_teardown([:custom_teardown_callback3,
                             :custom_teardown_method3,
                             :custom_teardown_callback1,
                             :custom_teardown_method1,
                             :custom_teardown_callback0,
                             :custom_teardown_method0,
                             :teardown],
                            test_case, [])

  assert_inherited_teardown([:teardown], nil)
  assert_called_fixtures(expected_teardown_calls, test_case)
end
test_without_option() click to toggle source
# File test-unit-3.3.4/test/test-fixture.rb, line 392
def test_without_option
  expected_teardown_calls = [:custom_teardown_callback3,
                             :custom_teardown_method3,
                             :custom_teardown_callback1,
                             :custom_teardown_method1,
                             :custom_teardown_callback0,
                             :custom_teardown_method0,
                             :teardown]
  test_case = assert_teardown(expected_teardown_calls, [])
  assert_inherited_teardown(expected_teardown_calls, test_case)

  assert_inherited_teardown([:teardown], nil)
  assert_called_fixtures(expected_teardown_calls, test_case)
end