Test::Output - Utilities to test STDOUT and STDERR messages.
Version 0.02
use Test::More tests => 4; use Test::Output; sub writer { print "Write out.\n"; print STDERR "Error out.\n"; } output_is( \&writer, "Write out.\n", "Error out.\n", 'Test STDOUT & STDERR' ); stdout_is(\&writer,"Write out.\n",'Test STDOUT'); stderr_is(sub { print "This is STDOUT\n"; writer(); }, "Error out.\n",'Test STDERR');
Test::Output provides functions to test date sent to both STDOUT and STDERR.
Test::Output ties STDOUT and STDERR using Test::Output::Tie.
All functions are exported.
output_is ( $coderef, $expected_stdout, $expected_stderr, 'comment' ); output_isnt( $coderef, $expected_stdout, $expected_stderr, 'comment' );
output_is() compares the output of $coderef to $expected_stdout and $expected_stderr, and fails if they do not match. output_isnt() being the opposite fails if they do match.
In output_isnt() setting either $expected_stdout or $expected_stderr to undef ignores STDOUT or STEDERR during the test.
undef
stdout_is ( $coderef, $expected, 'comment' ); stdout_isnt( $coderef, $expected, 'comment' );
stdout_is() is similar to output_is() except that it only compares $expected to STDOUT captured from $codref. stdout_isnt() is the opposite.
stderr_is ( $coderef, $expected, 'comment' ); stderr_isnt( $coderef, $expected, 'comment' );
stderr_is() is similar to output_is(), and stdout_is() except that it only compares $expected to STDERR captured from $codref. Again stderr_isnt() is the opposite.
Shawn Sorichetti, <ssoriche@coloredblocks.net>
<ssoriche@coloredblocks.net>
Please report any bugs or feature requests to bug-test-output@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-test-output@rt.cpan.org
Thanks to chromatic whose TieOut.pm was the basis for capturing output.
Copyright 2005 Shawn Sorichetti, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Output, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Output
CPAN shell
perl -MCPAN -e shell install Test::Output
For more information on module installation, please visit the detailed CPAN module installation guide.