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.331
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 Ricardo Signes <rjbs@cpan.org>
46
48 This software is copyright (c) 2016 by Ricardo Signes.
49
50 This is free software; you can redistribute it and/or modify it under
51 the same terms as the Perl 5 programming language system itself.
52
53
54
55perl v5.30.1 2020-01-2A9pp::Cmd::Tester::CaptureExternal(3)