Click here to get back home

Testing stdout output modules

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Testing stdout output modules * Tong * 12-28-2006
Posted by * Tong * on December 28, 2006, 11:26 am
Please log in for more thread options


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


Posted by Uri Guttman on December 28, 2006, 12:33 pm
Please log in for more thread options



*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

Posted by Peter Scott on December 29, 2006, 7:34 am
Please log in for more thread options


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/Output.pm

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


Similar ThreadsPosted
Testing database code in CPAN modules April 4, 2005, 12:33 pm
SSH Modules: Accessing CLI box using SSH and not getting the return output?? November 12, 2006, 11:48 pm
Template-Toolkit: Flushing Output or Incremental Output, how? September 13, 2007, 2:45 pm
ANNOUNCE: IO::Capture::Stdout::Extended 0.03 March 2, 2005, 4:01 am
New module for testing January 5, 2007, 1:17 pm
Testing RPC::XML goes awry -- Newbie alert November 24, 2004, 8:39 am
output-monitoring module April 6, 2005, 11:38 am
getting output of telnet from perl April 6, 2006, 6:03 am
How to log the output of Mime::Lite ? June 26, 2006, 6:52 pm
Sending output to Spreadsheet January 3, 2007, 12:22 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap