Class: MicroTest::TestCase

Inherits:
World
  • Object
show all
Defined in:
lib/microtest.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Assertions

#assert, #assert_block, #assert_equal, #assert_in_delta, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_no_match, #assert_not_equal, #assert_not_nil, #assert_not_same, #assert_operator, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_throws, #flunk

Class Method Details

.inherited(subclass) ⇒ Object

When the TestCase class is inherited, a new instance is automatically created.



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

def self.inherited(subclass)
  subclass.new
end

.new(*a, &b) ⇒ Object

Create a new test and add it the the $TEST_SUITE global variable.



36
37
38
# File 'lib/microtest.rb', line 36

def self.new(*a,&b)
  $TEST_SUITE << super(*a,&b)
end

Instance Method Details

#call(&cont) ⇒ Object

Wrap test case run.

@todo: Support setup-all and teardown-all in future ?



52
53
54
55
56
# File 'lib/microtest.rb', line 52

def call(&cont)
  #setup_all
  cont.call
  #teardown_all
end

#eachObject

Iterate over each test.



61
62
63
64
65
66
# File 'lib/microtest.rb', line 61

def each
  methods.each do |m|
    next unless m.to_s.start_with?('test_')
    yield(TestMethod.new(self, method(m)))
  end
end

#setupObject

No-op for test setup routine.



71
72
# File 'lib/microtest.rb', line 71

def setup
end

#teardownObject

No-op for test teardown routine.



77
78
# File 'lib/microtest.rb', line 77

def teardown
end

#to_sObject

Returns name of testcase class.



43
44
45
# File 'lib/microtest.rb', line 43

def to_s
  self.class.name
end