App::Cmd::Tester(3)
π App::Cmd::Tester π
okay bestie, gather round, because this is the manual page for App::Cmd::Tester (that's the App::Cmd::Tester(3) one, iykyk) and honestly? it's a whole vibe. no cap.
β¨ VERSION β¨
this is version 0.338 π
πΈ SYNOPSIS πΈ
like, here's the whole thing in action:
use Test::More tests => 4;
use App::Cmd::Tester;
use YourApp;
my $result = test_app(YourApp => [ qw(command --opt value) ]);
like($result->stdout, qr/expected output/, 'printed what we expected');
is($result->stderr, '', 'nothing sent to sderr');
is($result->error, undef, 'threw no exceptions');
my $result = test_app(YourApp => [ qw(command --opt value --quiet) ]);
is($result->output, '', 'absolutely no output with --quiet');
(and yes, sderr is literally what it says up there β that's the original's spelling, not me being cute π)
π¦ DESCRIPTION π¦
so the tea is this: user-executed programs are like, notoriously badly tested, and the reason is literally just that they're hard to test. it's giving "we'll get to it later" energy. App::Cmd::Tester is one of the tools App-Cmd hands you to make testing App::Cmd-based programs actually easy instead of a whole ordeal.
it gives you exactly one routine: test_app. that's it. one. and she ate. π
π PERL VERSION π
this library is built to run on perls released, like, a long time ago. it should work on any version of perl released in the last five years. bestie it's flexible.
although it may work on older versions of perl, there is no guarantee that the minimum required version won't get increased. the version can be bumped for any reason, and there is no promise that patches will be accepted to lower the minimum required perl. so likeβ¦ don't come for her. π
π METHODS π
π test_app
note: even thoughtest_appis technically a method, it's by default exported as a subroutine into the namespace that usesApp::Cmd::Tester. in other words: you probably don't need to think about it as a method unless you want to subclassApp::Cmd::Tester. iykyk.
my $result = test_app($app_class => \@argv_contents);
so what she does is: locally set @ARGV to simulate command line arguments, and then call the run method on the given application class (or application). output to the standard output and standard error filehandles gets captured. obsessed.
$result is an App::Cmd::Tester::Result object, and she's got methods to get at all this data:
stdout - the output sent to stdout
stderr - the output sent to stderr
output - the combined output of stdout and stderr
error - the exception thrown by running the application, or undef
run_rv - the return value of the run method (generally irrelevant)
exit_code - the numeric exit code that would've been issued (0 is 'okay')
the output is captured using IO::TieCombine, which can make sure the ordering is preserved in the combined output β but it can't capture the output of external programs. π
you can reverse those tradeoffs by using App::Cmd::Tester::CaptureExternal instead. options, bestie! we love options. β¨
π AUTHOR π
Ricardo Signes <cpan@semiotic.systems>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2025 by Ricardo Signes.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt.
and that's the whole page, babe π«Ά this was App::Cmd::Tester(3) from the perl v5.42.0 docs, dated 2026-01-16 β go forth and test your apps, mwah ππΈ
π¦ where this page comes from
- fedora 44: perl-App-Cmd 0.338-2.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms