NAME
HTTP::WebTest::Plugins - Plugin developers documentation.
SYNOPSIS
Not applicable.
DESCRIPTION
This document is the starting point for developers who wish to extend HTTP::WebTest functionality with external plugins.
ABOUT PLUGINS
Plugin can be used to add new test types and add new report types. A plugin is just a Perl package that defines class with a number of methods which if present are called by HTTP::WebTest at various stages of test.
Each plugin package should subclass HTTP::WebTest::Plugin. Report plugins can subclass HTTP::WebTest::ReportPlugin which is a subclass of HTTP::WebTest::Plugin. HTTP::WebTest::ReportPlugin defines some helper methods useful in report plugins and handles some test parameters common for report plugins.
REQUIRED METHODS
Each plugin package must provide following method:
param_types
Returns
A string that contains information about supported test parameters and their types.
String has following format:
PARAM1 TYPE1 PARAM2 TYPE2 PARAM3 TYPE3 ... PARAMN TYPEN
PARAM is the name of a test parameter and TYPE is it's type specification. They should be separated by a whitespace character.
Each test parameter type is defined by a method in HTTP::WebTest::Plugin. Type foobar
is defined as method check_foobar
in this package. See its documentation for list of all check_****
methods - these methods define all known test types.
Example
sub param_types {
return q(ignore_case yesno
text_forbid list
text_require list
regex_forbid list
regex_require list);
}
This is from HTTP::WebTest::Plugin::TextMatchTest. It defines the test parameters ignore_case
, text_forbid
, text_require
, regex_forbid
and regex_require
. yesno
and list
are test parameter types.
OPTIONAL METHODS
Each plugin package may provide following methods:
start_tests ()
Called before runing test sequence. Initializations can be done in this method. Report plugins can use this hook to create the report header.
end_tests ()
Called when test sequence is finished. Clean-up and finalization can be done in this method. Report plugins can use this hook to finish the report.
prepare_request ()
Called just before HTTP::WebTest submits the HTTP request. Various properties of request can be set here.
check_response ()
Called after HTTP::WebTest gets the HTTP response. Web page tests should be placed here.
report_test ()
Called after all HTTP::WebTest <check_response> hooks are called. Normally used by report plugins to generate report about test just done.
Returns
These methods should return results of tests made in the following form:
[ [ TEST_GROUP1_NAME, TEST_RESULT1, TEST_RESULT2, ... ],
[ TEST_GROUP2_NAME, TEST_RESULT1, TEST_RESULT2, ... ],
...
];
TEST_GROUP_NAME
is a string that describes a group of web tests and their results. It is used during the generation of the test report.
TEST_RESULT
is an HTTP::WebTest::TestResult object.
EXAMPLES
Some examples of plugins are:
- HTTP::WebTest::Plugin::Cookies
-
Plugin that uses both
prepare_request
andcheck_response
hooks. - HTTP::WebTest::Plugin::StatusTest
-
Simple plugin that defines only the
check_response
hook. - HTTP::WebTest::Plugin::DefaultReport
-
Example of a report plugin. Uses
start_tests
,report_test
andend_tests
hooks.
COPYRIGHT
Copyright (c) 2001-2002 Ilya Martynov. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.