Skip to content

Instantly share code, notes, and snippets.

@riywo
Created August 30, 2011 03:14
Show Gist options
  • Save riywo/1180086 to your computer and use it in GitHub Desktop.
Save riywo/1180086 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Test::More;
open my $fh, '>', \(my $output_buffer = '');
Test::More->builder->output($fh);
Test::More->builder->failure_output($fh);
Test::More->builder->todo_output($fh);
note "hoge";
print "$output_buffer\n";
__END__
# hoge
use strict;
use warnings;
use Capture::Tiny qw/capture/;
use Test::More;
my ($stdout, $stderr) = capture { note "hoge" };
print "stdout: $stdout\n";
print "stderr: $stderr\n";
__END__
# hoge
stdout:
stderr:
use strict;
use warnings;
use Capture::Tiny qw/capture/;
use Test::More;
Test::More->builder->output(*STDOUT);
my ($stdout, $stderr) = capture { note "hoge" };
print "stdout: $stdout\n";
print "stderr: $stderr\n"
__END__
stdout: # hoge
stderr:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment