GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TEST::STREAM::PLUGIN::INTERCEPT (3)

.ds Aq ’

NAME

Test::Stream::Plugin::Intercept - Tool for intercepting test events.

CONTENTS

DEPRECATED

<B>This distribution is deprecatedB> in favor of Test2, Test2::Suite, and Test2::Workflow.

See Test::Stream::Manual::ToTest2 for a conversion guide.

SYNOPSIS



    # Load the Intercept plugin, and others we need
    use Test::Stream qw/Intercept Core Compare/;

    my $events = intercept {
        ok(1, foo);
        ok(0, bar);
    };

    is(@$events, 2, "intercepted 2 events.");

    isa_ok($events->[0], Test::Stream::Event::Ok);
    ok($events->[0]->pass, "first event passed");



EXPORTS

$events = intercept { ... } This lets you intercept all events inside the codeblock. All the events will be returned in an arrayref.



    my $events = intercept {
        ok(1, foo);
        ok(0, bar);
    };
    is(@$events, 2, "intercepted 2 events.");



There are also 2 named parameters passed in, context and hub. The context passed in is a snapshot of the context for the intercept() tool itself, referencing the parent hub. The hub parameter is the new hub created for the intercept run.



    my $events = intercept {
        my %params = @_;

        my $outer_ctx = $params{context};
        my $our_hub   = $params{hub};

        ...
    };



By 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 1 test. You can turn enforcement back one like this:



    my %params = @_;
    $params{hub}->set_no_ending(0);



With no_ending turned off, $hub-finalize()> 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.

<B>Note:B> the $ENV{TS_TERM_SIZE} environment variable is set to 80 inside the intercept block. This is done to ensure consistency for the block across machines and platforms. This is essential for predictable testing of diagnostics, which may render tables or use the terminal size to change behavior.

SEE ALSO

Test::Stream::Plugin::Grab - Similar tool, but allows you to intercept events without adding stack frames.

SOURCE

The source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

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/

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 TEST::STREAM::PLUGIN::INTERCEPT (3) 2016-02-05

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.