The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Output - Utilities to test STDOUT and STDERR messages.

VERSION

Version 0.02

SYNOPSIS

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

DESCRIPTION

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 output_isnt

   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.

stdout_is stdout_isnt

   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 stderr_isnt

   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.

AUTHOR

Shawn Sorichetti, <ssoriche@coloredblocks.net>

BUGS

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.

ACKNOWLEDGEMENTS

Thanks to chromatic whose TieOut.pm was the basis for capturing output.

COPYRIGHT & LICENSE

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.