1App::Cmd::Tester::CaptuUrseeErxtCeornntarli(b3u)ted PerlApDpo:c:uCmmedn:t:aTteisotner::CaptureExternal(3)
2
3
4
6 App::Cmd::Tester::CaptureExternal - Extends App::Cmd::Tester to capture
7 from external subprograms
8
10 version 0.335
11
13 use Test::More tests => 4;
14 use App::Cmd::Tester::CaptureExternal;
15
16 use YourApp;
17
18 my $result = test_app(YourApp => [ qw(command --opt value) ]);
19
20 like($result->stdout, qr/expected output/, 'printed what we expected');
21
22 is($result->stderr, '', 'nothing sent to sderr');
23
24 ok($result->output, "STDOUT concatenated with STDERR");
25
27 App::Cmd::Tester provides a useful scaffold for testing applications,
28 but it is unable to capture output generated from any external
29 subprograms that are invoked from the application.
30
31 This subclass uses an alternate mechanism for capturing output
32 (Capture::Tiny) that does capture from external programs, with one
33 major limitation.
34
35 It is not possible to capture externally from both STDOUT and STDERR
36 while also having appropriately interleaved combined output.
37 Therefore, the "output" from this subclass simply concatenates the two.
38
39 You can still use "output" for testing if there is any output at all or
40 for testing if something appeared in either output stream, but you
41 can't rely on the ordering being correct between lines to STDOUT and
42 lines to STDERR.
43
45 This library should run on perls released even a long time ago. It
46 should work on any version of perl released in the last five years.
47
48 Although it may work on older versions of perl, no guarantee is made
49 that the minimum required version will not be increased. The version
50 may be increased for any reason, and there is no promise that patches
51 will be accepted to lower the minimum required perl.
52
54 Ricardo Signes <cpan@semiotic.systems>
55
57 This software is copyright (c) 2022 by Ricardo Signes.
58
59 This is free software; you can redistribute it and/or modify it under
60 the same terms as the Perl 5 programming language system itself.
61
62
63
64perl v5.36.0 2023-01-1A9pp::Cmd::Tester::CaptureExternal(3)