SPUG: HTTP::WebTest released to CPAN

Richard Anderson starfire at zipcon.net
Sat Jan 13 11:12:15 CST 2001


As some of you know, I've been working on a Perl module for unit testing of
remote URL's or local web files containing Perl/HTML/Javascript/etc.  This
was released to CPAN today and is available for download.  Here are the
particulars:

NAME
    HTTP::WebTest - Test remote URLs or local web files

DESCRIPTION
    This module runs tests on remote URLs or local web files containing
    Perl/HTML/JavaScript/etc. and generates a detailed test report. The
    test specifications can be read from a parameter file or input as
    method arguments. If you are testing a local file, Apache is
    started on a private/dynamic port with a configuration file in a
    temporary directory.  The module displays the test results on the
    terminal by default or directs them to a file. The module will also
    optionally e-mails the test results. When the calling program
    exits, the module stops the local instance of Apache and deletes
    the temporary directory.

    Each test consists of literal strings or regular expressions that
    are either required to exist or forbidden to exist in the fetched
    page. You can also specify tests for the minimum and maximum number
    of bytes in the returned page. If you are testing a local file, the
    module checks the error log in the temporary directory before and
    after the file is fetched from Apache. If messages are written to
    the error log during the fetch, the module flags this as an error
    and writes the messages to the output test report.

SYNOPSIS
     This module can accept input parameters from a parameter file or
     subroutine arguments.

     TO RUN WEB TESTS DEFINED BY SUBROUTINE ARGUMENTS:

     use HTTP::WebTest; run_web_test(\@web_tests, \$num_fail,
        \$num_succeed, \%test_options)

     or

     use HTTP::WebTest; run_web_test(\@web_tests, \$num_fail,
        \$num_succeed)

     TO RUN WEB TESTS DEFINED BY A PARAMETER FILE:

     use sigtrap qw(die normal-signals); # Recommended, not necessary
     use HTTP::WebTest; $webtest = HTTP::WebTest->new();
     $webtest->web_test('my_web_tests.wt', \$num_fail, \$num_succeed);

     The web_test() method has an option to test a local file by
     starting Apache on a private port, copying the file to a temporary
     htdocs directory and fetching the page from Apache.  If you are
     testing with multiple parameter files, you can avoid restarting
     Apache each time by calling new() only once and recycling the
     object:

     use sigtrap qw(die normal-signals); # Recommended, not necessary
     use HTTP::WebTest;
     $webtest = HTTP::WebTest->new();
     foreach $file (@ARGV) {
        $webtest->web_test($file, \$num_fail, \$num_succeed);
     }

     TO ENABLE DEBUGGING MESSAGES (OUTPUT TO STDOUT):

     If you are calling the web_test method, use the debug parameter.
     If you are calling the run_web_test method, do this:

     use HTTP::WebTest;
     $HTTP::WebTest::Debug = 1; # Diagnostic messages
     $HTTP::WebTest::Debug = 2; # Messages and preserve temp Apache dir
     run_web_test(\@web_tests, \$num_fail, \$num_succeed)

RESTRICTIONS / BUGS
    This module only works on Unix (e.g., Solaris, Linux, AIX, etc.).
    The module's HTTP requests time out after 3 minutes (the default
    value for LWP::UserAgent). If the file_path parameter is specified,
    Apache must be installed. If the file_path parameter is specified,
    the directory /tmp cannot be NFS-mounted, since Apache's lockfile
    and the SSL mutex file must be stored on a local disk.

VERSION
    This document describes version 0.01, release date 13 January 2001.

TODO
    Add option to validate HTML syntax using HTML::Validator. Add
    option to check links (see
    http://world.std.com/~swmcd/steven/perl/pm/lc/linkcheck.html).

AUTHOR
     Richard Anderson <Richard.Anderson at unixscripts.com>

COPYRIGHT
    Copyright (c) 2000 Richard Anderson. All rights reserved. This
    module is free software. It may be used, redistributed and/or
    modified under the terms of the Perl Artistic License.

Richard.Anderson at unixscripts.com              RayCosoft, LLC
Perl/Java/Oracle/Unix software engineering    www.unixscripts.com
www.zipcon.net/~starfire/home                     Seattle, WA, USA



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list