class RubyUnit::TestCase
All classes derrived from the RubyUnit::TestCase
will automatically be run by the test runner.
-
Test methods must currently be named ending in ‘Test’
-
Data methods must currently be named ending in ‘Data’ All data methods must return an array of arrays as param lists to passed to the corresponding test method.
-
Exceptions raised in this class are generally caught by the
RubyUnit::Runner
MyTest < RubyUnit::TestCase def simpleData [ [ 1, 3], ['string', nil], ], end def simpleTest param1, param2 # run assertions end end
Public Class Methods
Gets the current number of assertions that have been run while testing
# File lib/RubyUnit/TestCase.rb, line 106 def assertions @@assertions end
Gets a list of all the descendents of the RubyUnit::TestCase
class. This is important when determining the tests that have been defined.
# File lib/RubyUnit/TestCase.rb, line 97 def descendents ObjectSpace.each_object(Class).select do |object| object < self end end
The setup helper that is run before each test case begins running tests.
def self.setup # create objects, set up the scenario end
# File lib/RubyUnit/TestCase.rb, line 81 def setup end
The teardown helper that is run after each test case finishes running tests.
def self.teardown # destroy objects, clean up after yourself end
# File lib/RubyUnit/TestCase.rb, line 91 def teardown end
Public Instance Methods
Mark the test as incomplete
markIncomplete 'Implementation of this test is not finished'
# File lib/RubyUnit/TestCase.rb, line 65 def markIncomplete message = nil raise IncompleteTest, message end
Mark the test as skipped
markSkipped 'This test is being refactored'
# File lib/RubyUnit/TestCase.rb, line 56 def markSkipped message = nil raise SkippedTest, message end
The setup helper that is run before each test in the test case.
def setup # create objects, set up the scenario end
# File lib/RubyUnit/TestCase.rb, line 38 def setup end
The teardown helper that is run after each test in the test case.
def teardown # destroy objects, clean up after yourself end
# File lib/RubyUnit/TestCase.rb, line 48 def teardown end