Name : perl-Test-Abortable
| |
Version : 0.3.0
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 150600.1.1
| Date : 2024-08-18 23:51:31
|
Group : Unspecified
| Source RPM : perl-Test-Abortable-0.3.0-150600.1.1.src.rpm
|
Size : 0.03 MB
| |
Packager : https://www_suse_com/
| |
Summary : Subtests That You Can Die Your Way Out of ... But Survive
|
Description :
Test::Abortable provides a simple system for catching some exceptions and turning them into test events. For example, consider the code below:
use Test::More; use Test::Abortable;
use My::API; # code under test
my $API = My::API->client;
subtest \"collection distinction\" => sub { my $result = $API->do_first_thing;
is($result->documents->first->title, \"The Best Thing\"); isnt($result->documents->last->title, \"The Best Thing\"); };
subtest \"document transcendence\" => sub { ... }; subtest \"semiotic multiplexing\" => sub { ... }; subtest \"homoiousios type vectors\" => sub { ... };
done_testing;
In this code, \'$result->documents\' is a collection. It has a \'first\' method that will throw an exception if the collection is empty. If that happens in our code, our test program will die and most of the other subtests won\'t run. We\'d rather that we only abort the _subtest_. We could do that in a bunch of ways, like adding:
return fail(\"no documents in response\") if $result->documents->is_empty;
...but this becomes less practical as the number of places that might throw these kinds of exceptions grows. To minimize code that boils down to \"and then stop unless it makes sense to go on,\" Test::Abortable provides a means to communicate, via exceptions, that the running subtest should be aborted, possibly with some test output, and that the program should then continue.
Test::Abortable exports a \'subtest\' routine that behaves like the one in Test::More|Test::More/subtest but will handle and recover from abortable exceptions (defined below). It also exports \'testeval\', which behaves like a block eval that only catches abortable exceptions.
For an exception to be \"abortable,\" in this sense, it must respond to a \'as_test_abort_events\' method. This method must return an arrayref of arrayrefs that describe the Test2 events to emit when the exception is caught. For example, the exception thrown by our sample code above might have a \'as_test_abort_events\' method that returns:
[ [ Ok => (pass => 0, name => \"->first called on empty collection\") ], ]
It\'s permissible to have passing Ok events, or only Diag events, or multiple events, or none — although providing none might lead to some serious confusion.
Right now, any exception that provides this method will be honored. In the future, a facility for only allowing abortable exceptions of a given class may be added.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl/SLE_15_SP6/noarch |