On Wed, Feb 13, 2002 at 04:11:59PM -0500, Kirrily 'Skud' Robert wrote:
> Using Test::More, how can I intersperse stuff for user interaction?  For
> instance:
> 
> print "Please enter the hostname/ip for the server [localhost]: ";
> my $host = <STDIN>;
> print "Please enter the admin password [default]: ";
> my $password = <STDIN>;
> $agent = esmith::FormMagick::Tester->new(host => $host, password => $password);
> isa_ok($agent, 'esmith::FormMagick::Tester');
> is($agent->{password}, $password || 'default', "Set password correctly");
> 
> Test::More takes control of so much stuff that my user prompts are never
> printed.

Test::Harness swallows everything that goes to STDOUT, so the user
will never see the prompts.  You could print them to STDERR, but that
will rapidly get messy.

Best bet is to ask any questions *before* running the tests.  In
MakeMaker terms that would be either by having Makefile.PL ask them 
or by overriding test_via_harness.

    {
        package MY;
        sub test_via_harness {
            my($self, $perl, $tests) = @_;

            #-> Ask your questions
            #-> Dump it out to a file

            $self->SUPER::test_via_harness($perl, $tests);
        }
    }       


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Instant Cross-Platform CGI Programming in Visual Perl 5 with Object Oriented
Design in 7 Days Unleashed for Dummies Special Edition with Exclusive Java
Chapters for Developers.  Year 2000 compliant, Enterprise edition and ISO9000-
certified.  A Nutshell Handbook Designed For Windows 95/98/NT with a forward by
Larry "Bud" Melman. Interactive Multimedia CDROM included.  3rd revised editon,
covers Perl5.6.
Of course, it will be refered to by its simple acronym:
ICPCGIPiVP5wOODi7DU4DSEwEJC4DY2KCEedISO9000-cNHD4W9598NTLBMIMCDROM3edP5.6

Reply via email to