Class: RubyUnit::TestCase

Inherits:
Object
  • Object
show all
Includes:
Assertions
Defined in:
lib/RubyUnit/TestCase.rb

Overview

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

Constant Summary

Constants included from AssertionMessage

AssertionMessage::ASSERT_CLASS_METHOD_ERROR, AssertionMessage::ASSERT_CONST_DEFINED_ERROR, AssertionMessage::ASSERT_CONST_ERROR, AssertionMessage::ASSERT_CONST_NOT_DEFINED_ERROR, AssertionMessage::ASSERT_DESCENDENT_ERROR, AssertionMessage::ASSERT_EMPTY_ERROR, AssertionMessage::ASSERT_EQUAL_ERROR, AssertionMessage::ASSERT_ERROR, AssertionMessage::ASSERT_FALSE_ERROR, AssertionMessage::ASSERT_GREATERTHANOREQUAL_ERROR, AssertionMessage::ASSERT_GREATERTHAN_ERROR, AssertionMessage::ASSERT_INCLUDE_ERROR, AssertionMessage::ASSERT_INSTANCE_METHOD_ERROR, AssertionMessage::ASSERT_INSTANCE_OF_ERROR, AssertionMessage::ASSERT_INSTANCE_VARIABLE_DEFINED_ERROR, AssertionMessage::ASSERT_INSTANCE_VARIABLE_EQUAL_ERROR, AssertionMessage::ASSERT_INSTANCE_VARIABLE_KIND_OF_ERROR, AssertionMessage::ASSERT_INSTANCE_VARIABLE_NOT_DEFINED_ERROR, AssertionMessage::ASSERT_INSTANCE_VARIABLE_NOT_EQUAL_ERROR, AssertionMessage::ASSERT_INSTANCE_VARIABLE_NOT_KIND_OF_ERROR, AssertionMessage::ASSERT_KIND_OF_ERROR, AssertionMessage::ASSERT_LESSTHANOREQUAL_ERROR, AssertionMessage::ASSERT_LESSTHAN_ERROR, AssertionMessage::ASSERT_MATCH_ERROR, AssertionMessage::ASSERT_METHOD_ERROR, AssertionMessage::ASSERT_NIL_ERROR, AssertionMessage::ASSERT_NOTHING_RAISED_ERROR, AssertionMessage::ASSERT_NOT_CLASS_METHOD_ERROR, AssertionMessage::ASSERT_NOT_DESCENDENT_ERROR, AssertionMessage::ASSERT_NOT_EMPTY_ERROR, AssertionMessage::ASSERT_NOT_EQUAL_ERROR, AssertionMessage::ASSERT_NOT_ERROR, AssertionMessage::ASSERT_NOT_INCLUDE_ERROR, AssertionMessage::ASSERT_NOT_INSTANCE_METHOD_ERROR, AssertionMessage::ASSERT_NOT_INSTANCE_OF_ERROR, AssertionMessage::ASSERT_NOT_KIND_OF_ERROR, AssertionMessage::ASSERT_NOT_MATCH_ERROR, AssertionMessage::ASSERT_NOT_METHOD_ERROR, AssertionMessage::ASSERT_NOT_NIL_ERROR, AssertionMessage::ASSERT_NOT_RESPOND_TO_ERROR, AssertionMessage::ASSERT_NOT_SAME_ERROR, AssertionMessage::ASSERT_RAISE_ERROR, AssertionMessage::ASSERT_RAISE_EXPECTED_ERROR, AssertionMessage::ASSERT_RAISE_KIND_OF_ERROR, AssertionMessage::ASSERT_RAISE_MESSAGE_ERROR, AssertionMessage::ASSERT_RESPOND_TO_ERROR, AssertionMessage::ASSERT_SAME_ERROR, AssertionMessage::ASSERT_TRUE_ERROR, AssertionMessage::FAILING, AssertionMessage::FAILURE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Assertions

add_assertion

Methods included from Assertions::Variables

#assertInstanceVariableDefined, #assertInstanceVariableEqual, #assertInstanceVariableKindOf, #assertInstanceVariableNotDefined, #assertInstanceVariableNotEqual, #assertInstanceVariableNotKindOf

Methods included from Assertions::Methods

#assertClassMethod, #assertInstanceMethod, #assertMethod, #assertNotClassMethod, #assertNotInstanceMethod, #assertNotMethod, #assertNotRespondTo, #assertRespondTo

Methods included from Assertions::Exceptions

#assertNothingRaised, #assertRaiseExpected, #assertRaiseKindOf, #assertRaiseMessage

Methods included from Assertions::Comparisons

#assertEqual, #assertGreaterThan, #assertGreaterThanOrEqual, #assertLessThan, #assertLessThanOrEqual, #assertMatch, #assertNotEqual, #assertNotMatch, #assertNotSame, #assertSame

Methods included from Assertions::Classes

#assertConst, #assertConstDefined, #assertConstNotDefined, #assertDescendent, #assertInstanceOf, #assertKindOf, #assertNotDescendent, #assertNotInstanceOf, #assertNotKindOf

Methods included from Assertions::Basic

#assert, #assertFalse, #assertNil, #assertNot, #assertNotNil, #assertTrue, #fail

Class Method Details

.assertionsObject

Gets the current number of assertions that have been run while testing



106
107
108
# File 'lib/RubyUnit/TestCase.rb', line 106

def assertions
  @@assertions
end

.descendentsObject

Gets a list of all the descendents of the RubyUnit::TestCase class. This is important when determining the tests that have been defined.



97
98
99
100
101
# File 'lib/RubyUnit/TestCase.rb', line 97

def descendents
  ObjectSpace.each_object(Class).select do |object|
    object < self
  end
end

.setupObject

The setup helper that is run before each test case begins running tests.

def self.setup
  # create objects, set up the scenario
end


81
82
# File 'lib/RubyUnit/TestCase.rb', line 81

def setup
end

.teardownObject

The teardown helper that is run after each test case finishes running tests.

def self.teardown
  # destroy objects, clean up after yourself
end


91
92
# File 'lib/RubyUnit/TestCase.rb', line 91

def teardown
end

Instance Method Details

#markIncomplete(message = nil) ⇒ Object

Mark the test as incomplete

markIncomplete 'Implementation of this test is not finished'

Raises:



65
66
67
# File 'lib/RubyUnit/TestCase.rb', line 65

def markIncomplete message = nil
  raise IncompleteTest, message
end

#markSkipped(message = nil) ⇒ Object

Mark the test as skipped

markSkipped 'This test is being refactored'

Raises:



56
57
58
# File 'lib/RubyUnit/TestCase.rb', line 56

def markSkipped message = nil
  raise SkippedTest, message
end

#setupObject

The setup helper that is run before each test in the test case.

def setup
  # create objects, set up the scenario
end


38
39
# File 'lib/RubyUnit/TestCase.rb', line 38

def setup
end

#teardownObject

The teardown helper that is run after each test in the test case.

def teardown
  # destroy objects, clean up after yourself
end


48
49
# File 'lib/RubyUnit/TestCase.rb', line 48

def teardown
end