Error::Hierarchy::Test - tools to test hierarchical exceptions
throws2_ok { # ... }, 'Some::Exception', qr/text that \s* appears in the exception message/, "this test's name";
This module provides some tools that help in testing hierarchical exceptions.
exception_ok
Takes as arguments in the given order: an exception object, a class name, the expected content and optionally a test name.
First we check whether the exception object is of the given class type. If it is, we also check whether the stringified exception matches the expected content. If the content is a string, the content has to be equal to the stringified exception. If the content is a regex, the content has to match the stringified exception.
The first argument can also be a Error::Hierarchy::Container, in which case the first exception stored in the container will be tested.
If the test name is not given, the stringified exception is used.
Otherwise it behaves like Test::More's ok(). If the test was not ok, a diagnostic is printed.
ok()
throws2_ok
Takes as arguments in the given order: A code reference, a class name, the expected content and optionally a test name.
The code reference is executed in a try/catch block. The test is ok if the code threw the given exception, with semantics per exception_ok().
try
catch
exception_ok()
Diagnostics are printed if the exception did not match the expectations, or if no exception was thrown.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org.
See perlmodinstall for information and options on installing Perl modules.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN site near you. Or see http://search.cpan.org/dist/Error-Hierarchy/.
Marcel Grünauer, <marcel@cpan.org>
<marcel@cpan.org>
Copyright 2004-2009 by the authors.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Error::Hierarchy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Error::Hierarchy
CPAN shell
perl -MCPAN -e shell install Error::Hierarchy
For more information on module installation, please visit the detailed CPAN module installation guide.