Test harness for scripts?

Discussion in 'Perl Misc' started by bwooster47@gmail.com, May 16, 2007.

  1. Guest

    When creating Perl modules, there is Test::More and similar tools
    available to automate the testing.

    Are there general guidelines for writing test scripts that work with
    the Test::Harness framework?

    I noticed Test::Script - it offers one function -
    "script_compiles_ok()"

    But if I need more - what are some good practices for testing the full
    script:

    1) run script with --arg1 --arg2, check that STDOUT has a line with
    "text line 1"
    2) run script with --arg3 file, check that file was created (and then
    clean up - remove it)
    3) run script with --arg4, check that Unknown Arg error is thrown

    One option is just to write the perl code to execute the above
    commands, and do the checks. But how to run the command - "make test"
    puts the script in blib/script, the script itself is in bin/, and
    there may be a system installed old script version, so need to make
    sure that the test is running the script from the development folder.

    Any suggestions?
     
    , May 16, 2007
    #1
    1. Advertising

  2. Sisyphus Guest

    <> wrote in message
    news:...
    > When creating Perl modules, there is Test::More and similar tools
    > available to automate the testing.
    >
    > Are there general guidelines for writing test scripts that work with
    > the Test::Harness framework?


    Any file with a '.t' extension that's placed in the './t' folder will be
    automatically run by 'make test'.
    There are other options, too, but that's how most people create their test
    scripts.

    ..
    ..
    > But how to run the command - "make test"
    > puts the script in blib/script, the script itself is in bin/, and
    > there may be a system installed old script version, so need to make
    > sure that the test is running the script from the development folder.
    >


    I don't think this is a consideration at all.
    The test scripts themselves (ie the '.t' scripts in the './t' folder) don't
    get put into blib - they stay where they are.
    Also, 'make test' will find (and use) the files in blib *before* it goes
    looking for files (in @INC) that have been installed into perl as a result
    of an earlier build. (That is, if the file exists in blib, then that's the
    one that 'make test' is going to use.)

    Cheers,
    Rob
     
    Sisyphus, May 17, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fabbl

    Test Harness Strategies

    fabbl, Apr 17, 2004, in forum: VHDL
    Replies:
    1
    Views:
    1,066
    Jim Lewis
    Apr 17, 2004
  2. Todd
    Replies:
    0
    Views:
    333
  3. Troy Denkinger

    Test Harness?

    Troy Denkinger, Mar 9, 2006, in forum: Ruby
    Replies:
    10
    Views:
    249
    Troy Denkinger
    Mar 10, 2006
  4. yusuf
    Replies:
    2
    Views:
    145
    yusuf
    Aug 7, 2006
  5. yusuf

    Test::Harness and test values.

    yusuf, Aug 7, 2006, in forum: Perl Misc
    Replies:
    4
    Views:
    117
    yusuf
    Aug 9, 2006
Loading...

Share This Page