test-unit

The Test::Unit library includes the following changes.

Additional Instance Methods

Test::Unit::TestCase#startup

This hook is called only once, prior to any tests being run for the given test suite. Compare versus the setup method, which is called once per test.

Handy for one time operations, like socket connections.

Test::Unit::TestCase#shutdown

This hook is called only once, after all tests have been run for the given test suite. Compare versus the teardown method, which is called once per test.

Generally used in conjunction with the startup method.

Test::Unit::Assertions#assert_raise_kind_of(parent_error_class)

For those cases where you know a test should raise an error, but you can't predict exactly what kind of error it will raise. Primarily useful for dealing with system specific errors in a more general way, where different platforms may raise different errors, but you cannot know in advance exactly which error will be raised.

Test::Unit::Assertions#assert_boolean(value)

Used to check if value is true or false.

Test::Unit::Assertions#assert_false(condition)

Handy shortcut for assert_equal(false, ...)

Test::Unit::Assertions#assert_true(condition)

Handy shortcut for assert_equal(true, ...)

Test::Unit::Assertions#assert_raise_message(message){ code }

Tests that the specific error message is raised by the provided block.

Test::Unit::Assertions#skip(message){ condition }

Allows you to skip a given test based on condition, which is then tallied as a skipped test by the runner. The message is optional.

Typically used for platform specific tests.

skip example

Removed Instance Methods

Test::Unit::Assertions#assert_raises

Removed, deprecated.

Acknowledgements

Thanks go to Edwin Fine for the original source code for the assert_raise_kind_of method.

Also available in: HTML TXT