Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
OK, I am still getting the same output (see below) and I think I am beginning to understand why ... so I hope my fellow Monks will excuse my ox-like progress ... :^)

In the script I am testing, what is now the sub main() calls out to a parse_opts() routine to set the values in %params. Therefore (if I am understanding this), the line I have added to myScript to enable testing, e.g.

main( @ARGV ) unless caller( );

... doesn't really make sense because the script isn't accessing @ARGV directly -- it is doing so via Getopt::Long and a parse_opts() routine. In other words there is kind of a collision of approaches here.

... so I am still lost in a way. Am not sure if I need to totally recast the script to be tested so that it doesn't make use of this form of parameter processing, or if there is still a way to do what I want, e.g. write a test that allows one to point the script at a particular file, read 'dummy' input and create 'dummy' output, and test that that is all being done correctly.

For what it is worth, this is what test_myScript.t looks like now:

#!/usr/bin/perl use warnings; use strict; use Test::More tests => 5; use Test::Exception; ok( require( 'pluck4gl' ), 'loaded file okay' ) or exit; my @ARGV = ('-files=S2008-10-22_13:01.failed.lis','-output=doodad.4gl' +,'/data/mola/sap/daily4gl/S2008-10-22_13:01.4gl'); throws_ok (sub {main ( @ARGV )}, qr/Usage:/, 'main () should give a us +age error without any arguments'); throws_ok (sub {main( 'bad command' ) }, qr/Unknown command 'bad comma +nd'/, '... or with a bad command given');

... and here is the output:

1..5 ok 1 - loaded file okay parameter `files' not set parameter `output' not set # Looks like you planned 5 tests but only ran 1. # Looks like your test died just after 1.

I apologize for my utter fecklessness. I definitely need some more feck.

Thanks,

G


In reply to Re^4: testing a standalone script with parameters by chexmix
in thread testing a standalone script with parameters by chexmix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-03-28 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found