tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:
One thing I still haven't figured out how to test is, if you have a function that only prints output but doesn't return anything. Can someone teach me how to make this print "ok 1, ok 2"?
use strict; use warnings; use Test::More qw(no_plan); my $status = Status->new(); #how do I test this? $status->status('good'); # should be "ok" if the right message got pri +nted $status->status('bad'); # should also be "ok" if the right warning got + printed package Status; sub new { my $package = shift; my $self = {}; bless $self, $package; } sub status { my $self = shift; my $status = shift; if ($status eq 'good') { print "good status\n"; } else { warn "bad status\n"; } } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do you Test that the right output got printed?
by brian_d_foy (Abbot) on Jul 27, 2005 at 18:49 UTC | |
|
Re: How do you Test that the right output got printed?
by adrianh (Chancellor) on Jul 27, 2005 at 18:51 UTC | |
|
Re: How do you Test that the right output got printed?
by blokhead (Monsignor) on Jul 27, 2005 at 18:28 UTC | |
|
Re: How do you Test that the right output got printed?
by jeffa (Bishop) on Jul 27, 2005 at 18:05 UTC | |
|
Re: How do you Test that the right output got printed?
by mrborisguy (Hermit) on Jul 27, 2005 at 18:18 UTC | |
|
Re: How do you Test that the right output got printed?
by kwaping (Priest) on Jul 27, 2005 at 18:09 UTC |