Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Interactive Tests

by starX (Chaplain)
on Feb 15, 2008 at 19:31 UTC ( [id://668228]=perlquestion: print w/replies, xml ) Need Help??

starX has asked for the wisdom of the Perl Monks concerning the following question:

In developing my latest module, I've run into a problem that I haven't been able to easily solve through the usual testing mechanisms. These modules need to parse a vendor supplied spread sheet, and then format the data to match what we have in our database.

The first problem is that the vendor supplied price sheets are seldom consistent, even even when coming from the same vendor, so there are some run time control mechanisms that I've been using in the application to control that.

The second problem is that, depending on the type of product line, products should be formatted differently, and after speaking with some of the operations folks, they've decided that the easiest way might be to have whoever is importing the price sheet do a visual check of the output.

So in the first case, I would like to be able to specify to the test a couple items at run time (like the vendor and the price sheet), and in the second, I would like the test to display an example of the output and ask the user if it looks okay.

Unfortunately my efforts to pass in command line parameters (make test VENDOR /path/to/file) to the test using:

my $vendor - shift @ARGV; my $price_file = shift @ARGV;
Appear to have failed, but I must confess that this appearance of failure may be that Test::More is swallowing up all standard output. Which is consequently why I can't do this:
print "Item $item_number is formatted like $description\n", "Is this okay? (Y/N): "; my $ok_description = <STDIN>; chomp($ok_description)l ok($ok_description =~ /^Y/, 'Description looks okay');
So far the best advice I could find was that Test::More does in fact swallow up all STDOUT, and that if I wanted it to work this way, I could try using STDERR, but that seems like it could easily lead to its own problems down the line.

Anyone have any advice on how to proceed? Or does this sound like something Test::More won't be able to handle?

Replies are listed 'Best First'.
Re: Interactive Tests
by chromatic (Archbishop) on Feb 15, 2008 at 22:54 UTC

    Do you mean Test::Harness? If not, I'm confused (and I wrote a few pieces of Test::More. If so, then whatever happens when you type make test is important. It probably launches a program which uses T::H which launches your tests... but I can't guarantee that without seeing your Makefile. If that is the case, then you need to modify that code to pass arguments to your test files.

    However, if this were my project, I'd remove all traces of interactivity from the tests, as you lose the prime benefit of automated tests if you remove automation. It's okay to use separate, manual tests as long as you're clear that they're separate and manual.

      Thanks for the guidance, chromatic. The more I've thought about it, the more it makes sense to have the automatic tests do basic things like make sure key data is present (not undef), and then print a note about running a manual format check to be sure. I'm thinking the folks in Ops won't have a problem with that as long as I make it very clear which separate test they should run.
Re: Interactive Tests
by Your Mother (Archbishop) on Feb 15, 2008 at 22:55 UTC

    Maybe you want diag("Test escaped, asynchronous output here");?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://668228]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found