Testing stdout output modules
am 28.12.2006 17:26:11 von sun_tong_001
Hi,
I want to use the Test.pm from the standard Perl distribution to test my
module, but the problem is that the output of my module is writing to
stdout. Do I have to use something else or there are workarounds?
thanks
--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/
--
Posted via a free Usenet account from http://www.teranews.com
Re: Testing stdout output modules
am 28.12.2006 18:33:52 von Uri Guttman
>>>>> "*T*" == * Tong * <* > writes:
*T*> Hi,
*T*> I want to use the Test.pm from the standard Perl distribution to test my
*T*> module, but the problem is that the output of my module is writing to
*T*> stdout. Do I have to use something else or there are workarounds?
what does that have to do with Test.pm? you need to find a way to grab
the output of your module and then test those results. you can use a
localized STDOUT in a scope and then call your module. you can write a
wrapper script to drive your module and call it with `` from the test
script. but having a module write directly to stdout is a poor
idea. either pass in a handle (you could default it to stdout) or have
the module just return the text and let its caller do the printing. by
printing directly you force the module to be used in only one way which
is not a good design.
and you should look into using Test::More or some other better version
of Test.pm which is rather limited.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Re: Testing stdout output modules
am 29.12.2006 13:34:36 von Peter Scott
On Thu, 28 Dec 2006 16:26:11 +0000, * Tong * wrote:
> I want to use the Test.pm from the standard Perl distribution to test my
> module, but the problem is that the output of my module is writing to
> stdout. Do I have to use something else or there are workarounds?
http://search.cpan.org/~ssoriche/Test-Output-0.10/lib/Test/O utput.pm
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/