Class: Test::Unit::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/tap/test/unit.rb,
lib/tap/test/unit.rb

Overview

Test::Unit shims (< ruby 1.9)

:stopdoc: Implementing skip_test in the original Test::Unit is considerably more tricky than in the Mini::Test Test::Unit.

Class Method Summary collapse

Class Method Details

.inherited(child) ⇒ Object



46
47
48
49
50
51
# File 'lib/tap/test/unit.rb', line 46

def inherited(child)
  super
  tap_original_test_case_inherited(child)
  child.instance_variable_set(:@skip_messages, [])
  child.instance_variable_set(:@run_test_suite, true)
end

.original_suiteObject



60
# File 'lib/tap/test/unit.rb', line 60

alias :original_suite :suite

.skip_test(msg = nil) ⇒ Object

Causes a test suite to be skipped. If a message is given, it will print and notify the user the test suite has been skipped.



17
18
19
20
# File 'lib/tap/test/unit.rb', line 17

def skip_test(msg=nil)
  @@test_suites.delete(self)
  puts "Skipping #{self}#{msg.empty? ? '' : ': ' + msg}"
end

.suiteObject

Modifies the default suite method to skip the suit unless run_test_suite is true. If the test is skipped, the skip_messages will be printed along with the default ‘Skipping <Test>’ message.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/tap/test/unit.rb', line 65

def suite # :nodoc:
  if @run_test_suite
    original_suite
  else
    skip_message = @skip_messages.compact.join(', ')
    puts "Skipping #{name}#{skip_message.empty? ? '' : ': ' + skip_message}"

    # return an empty test suite of the appropriate name
    Test::Unit::TestSuite.new(name)
  end
end

.tap_original_test_case_inheritedObject



44
# File 'lib/tap/test/unit.rb', line 44

alias tap_original_test_case_inherited inherited