This module has been in use at an Internet 100 company for a few months.
I invite your comments on the interface and functionality. The
priorities on the TODO list are adding HTML syntax checking and dead
link checking, but these will be done after I release the module to CPAN.
This module runs tests on one or more remote URLs or local
files containing HTML/JavaScript/Perl/etc. The test
specifications are read from a parameter file or passed as
subroutine 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.
This module can accept input data 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 IN 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 VERBOSE DEBUGGING MESSAGES:
If you are calling the run_web_test method, do this:
use HTTP::WebTest;
$HTTP::WebTest::Debug = 1; # Verbose messages
$HTTP::WebTest::Debug = 2; # Messages and preserve temp dir
If you are calling the web_test method, use the debug parameter.
There are over 30 parameters, so I will not include all the documentation
in this post. If you are interested, I can e-mail them to you.
What do you think?
[EMAIL PROTECTED] RayCosoft
Perl/Java/SQL/Unix software engineering www.rayCosoft.com
www.zipcon.net/~starfire/home Seattle, WA, USA