Class: Test::Unit::TestCase

Inherits:
Object show all
Extended by:
Tap::Test::Extensions
Defined in:
lib/tap/test.rb

Overview

Methods extending TestCase. For more information see:

  • Tap::Test::SubsetTest

  • Tap::Test::FileTest

  • Tap::Test::TapTest

– See the TestTutorial for more information.

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Tap::Test::Extensions

acts_as_file_test, acts_as_script_test, acts_as_subset_test, acts_as_tap_test

Class Attribute Details

.run_test_suiteObject

Indicates when the test suite should be run or skipped.



29
30
31
# File 'lib/tap/test.rb', line 29

def run_test_suite
  @run_test_suite
end

.skip_messagesObject (readonly)

An array of messages printed when a test is skipped by setting run_test_suite to false.



33
34
35
# File 'lib/tap/test.rb', line 33

def skip_messages
  @skip_messages
end

Class Method Details

.inherited(child) ⇒ Object



21
22
23
24
25
26
# File 'lib/tap/test.rb', line 21

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



45
# File 'lib/tap/test.rb', line 45

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.



37
38
39
40
41
42
43
# File 'lib/tap/test.rb', line 37

def skip_test(msg=nil)
  self.run_test_suite = false

  # experimental -- perhaps use this so that a test can be skipped
  # for multiple reasons?
  skip_messages << 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.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/tap/test.rb', line 50

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



19
# File 'lib/tap/test.rb', line 19

alias tap_original_test_case_inherited inherited