|
NAMETest2::Util::Grabber - Object used to temporarily intercept all events.DESCRIPTIONOnce created this object will intercept and stash all events sent to the shared Test2::Hub object. Once the object is destroyed, events will once again be sent to the shared hub.SYNOPSISuse Test2 qw/Core Grab/; my $grab = grab(); # Generate some events, they are intercepted. ok(1, "pass"); ok(0, "fail"); my $events_a = $grab->flush; # Generate some more events, they are intercepted. ok(1, "pass"); ok(0, "fail"); # Same as flush, except it destroys the grab object. my $events_b = $grab->finish; After calling "finish()" the grab object is destroyed and $grab is set to undef. $events_a is an arrayref with the first two events. $events_b is an arrayref with the second two events. EXPORTS
METHODS
ENDING BEHAVIORBy default the hub used has "no_ending" set to true. This will prevent the hub from enforcing that you issued a plan and ran at least one test. You can turn enforcement back one like this:$grab->hub->set_no_ending(0); With "no_ending" turned off, "finish" will run the post-test checks to enforce the plan and that tests were run. In many cases this will result in additional events in your events array. SEE ALSOTest2::Tools::Intercept - Accomplish the same thing, but using blocks instead.SOURCEThe source code repository for Test2 can be found at https://github.com/Test-More/Test2-Suite/.MAINTAINERS
AUTHORS
COPYRIGHTCopyright 2018 Chad Granum <exodist@cpan.org>.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
Visit the GSP FreeBSD Man Page Interface. |