App::Cmd::Tester man page on Pidora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Pidora logo
[printable version]

App::Cmd::Tester(3)   User Contributed Perl Documentation  App::Cmd::Tester(3)

NAME
       App::Cmd::Tester - for capturing the result of running an app

VERSION
       version 0.311

SYNOPSIS
	 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');

DESCRIPTION
       One of the reasons that user-executed programs are so often poorly
       tested is that they are hard to test.  App::Cmd::Tester is one of the
       tools App-Cmd provides to help make it easy to test App::Cmd-based
       programs.

       It provides one routine: test_app.

METHODS
   test_app
       Note: while "test_app" is a method, it is by default exported as a
       subroutine into the namespace that uses App::Cmd::Tester.  In other
       words: you probably don't need to think about this as a method unless
       you want to subclass App::Cmd::Tester.

	 my $result = test_app($app_class => \@argv_contents);

       This will locally set @ARGV to simulate command line arguments, and
       will then call the "run" method on the given application class (or
       application).  Output to the standard output and standard error
       filehandles  will be captured.

       $result is an App::Cmd::Tester::Result object, which has methods to
       access the following 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')

AUTHOR
       Ricardo Signes <rjbs@cpan.org>

COPYRIGHT AND LICENSE
       This software is copyright (c) 2011 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.

perl v5.14.1			  2011-03-18		   App::Cmd::Tester(3)
[top]

List of man pages available for Pidora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net