Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: How to Test Output from the Standard Output

by snoopy (Deacon)
on Jun 10, 2010 at 05:42 UTC ( #843971=note: print w/replies, xml ) Need Help??

in reply to How to Test Output from the Standard Output

See also Test::Output. This provides some utility functions to do exactly this.
use strict; use Test::Output; use Test::More tests => 1; use Test_Package; stdout_is( sub{Test_Package->testing()}, 'okay', 'Testing okay');

Replies are listed 'Best First'.
Re^2: How to Test Output from the Standard Output
by Khen1950fx (Canon) on Jun 10, 2010 at 10:18 UTC
    Test::Output is interesting, but I had to make a few adjustments to get it to work. I took Grandfather's script, added a test from Test::Output.
    package Test_Package; use strict; sub testing { print "okay"; }; 1; use strict; use Test::Output; use Test::More tests => 4; my $log; open my $logFile, '>', \$log; my $oldStdOut = select $logFile; Test_Package->testing(\$log); select $oldStdOut; close $logFile; stdout_is {print "okay"} "okay", "STDOUT okay"; is('okay', 'okay'); is($log, 'okay'); is($log, 'okay', 'testing okay');

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://843971]
[stevieb]: Joan Jett, Hendrix, Neil Young, Dave Keuning (The Killers)... I have my mind elsewhere so I'm limited in my capacity to think about this righ tnow ;)
[erix]: another blues with Big Red :)
[stonecolddevin]: I will say John Mayer is an excellent guitarist, I don't like his music but he's pretty damn good
[erix]: scd: maybe you like John Mayall better :)
[erix]: (mayall = british blues)
[planetscape]: sleep well, Corion
[stonecolddevin]: erix seems pretty good, i listened to "So Many Roads" and it was nice. Not everyone's cup of tea but this guy can absolutely shred, he and the guy from Mastodon are definitely up there: https://www. v=VzhMkSN9dQc

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-06-22 21:42 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (531 votes). Check out past polls.