| Class | Test::Unit::TestCase |
| In: |
lib/test/unit/testcase.rb
|
| Parent: | Object |
Ties everything together. If you subclass and add your own test methods, it takes care of making them into tests and wrapping those tests into a suite. It also does the nitty-gritty of actually running an individual test and collecting its results into a Test::Unit::TestResult object.
You can run two hooks before/after a TestCase run.
Example:
class TestMyClass < Test::Unit::TestCase
class << self
def startup
...
end
def shutdown
...
end
end
def setup
...
end
def teardown
...
end
def test_my_method1
...
end
def test_my_method2
...
end
end
Here is a call order:
| method_name | [R] |
Describes a test.
The following example associates "register a normal user" description with "test_register" test.
description "register a normal user"
def test_register
...
end
Called after every test case runs. Can be used to tear down fixture information used in test case scope.
Here is an example test case:
class TestMyClass < Test::Unit::TestCase
class << self
def shutdown
...
end
end
def teardown
...
end
def test_my_class1
...
end
def test_my_class2
...
end
end
Here is a call order:
Note that you should not assume test order. Tests should be worked in any order.
Called before every test case runs. Can be used to set up fixture information used in test case scope.
Here is an example test case:
class TestMyClass < Test::Unit::TestCase
class << self
def startup
...
end
end
def setup
...
end
def test_my_class1
...
end
def test_my_class2
...
end
end
Here is a call order:
Note that you should not assume test order. Tests should be worked in any order.
Sets the current test order.
Here are the available order:
Returns a description for the test. A description will be associated by Test::Unit::TestCase.test or Test::Unit::TestCase.description.
Returns a name for the test for no description test.
Runs the individual test method represented by this instance of the fixture, collecting statistics, failures and errors in result.
Called before every test method runs. Can be used to set up fixture information.
You can add additional setup tasks by the following code:
class TestMyClass < Test::Unit::TestCase
def setup
...
end
setup
def my_setup1
...
end
setup
def my_setup2
...
end
def test_my_class
...
end
end
Here is a call order:
Called after every test method runs. Can be used to tear down fixture information.
You can add additional teardown tasks by the following code:
class TestMyClass < Test::Unit::TestCase
def teardown
...
end
teardown
def my_teardown1
...
end
teardown
def my_teardown2
...
end
def test_my_class
...
end
end
Here is a call order: