1Test::Stream::Plugin::CUaspetrurCeo(n3t)ributed Perl DocTuemsetn:t:aSttiroenam::Plugin::Capture(3)
2
3
4
6 Test::Stream::Plugin::Capture - Plugin for capturing STDERR and STDOUT.
7
9 This distribution is deprecated in favor of Test2, Test2::Suite, and
10 Test2::Workflow.
11
12 See Test::Stream::Manual::ToTest2 for a conversion guide.
13
15 This plugin provides the "capture { ... }" function which can be used
16 to capture all STDERR and STDOUT output from the code in the provided
17 codeblock. This will not intercept TAP output from Test::Stream
18 itself, so it is safe to run tests within the block.
19
21 is(
22 capture {
23 print STDERR "First STDERR\n";
24 print STDOUT "First STDOUT\n";
25 print STDERR "Second STDERR\n";
26 print STDOUT "Second STDOUT\n";
27 },
28 {
29 STDOUT => "First STDOUT\nSecond STDOUT\n",
30 STDERR => "First STDERR\nSecond STDERR\n",
31 },
32 "Captured stdout and stderr"
33 );
34
36 $out = capture { ... }
37 Captures all STDERR and STDOUT output within the codeblock. $out
38 will be a hashref with STDERR and STDOUT as keys. All output is
39 combined into a single string per handle.
40
42 The source code repository for Test::Stream can be found at
43 http://github.com/Test-More/Test-Stream/.
44
46 Chad Granum <exodist@cpan.org>
47
49 Chad Granum <exodist@cpan.org>
50
52 Copyright 2015 Chad Granum <exodist7@gmail.com>.
53
54 This program is free software; you can redistribute it and/or modify it
55 under the same terms as Perl itself.
56
57 See http://dev.perl.org/licenses/
58
59
60
61perl v5.28.0 2016-02-05 Test::Stream::Plugin::Capture(3)