NAME
HTTP::WebTest::Plugins - Plugin developers documentation.
SYNOPSIS
Not applicable.
DESCRIPTION
This document is good 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. Plugin is just a Perl package which 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 subclass of HTTP::WebTest::Plugin instead of it. HTTP::WebTest::ReportPlugin defines some helper methods useful in report plugin and handles some test parameters common for report plugins.
REQUIRED METHODS
Each plugin package should provide following method:
param_types
Returns
A string which contains information about supported test parameters and their types.
String has following format:
PARAM1 TYPE1 PARAM2 TYPE2 PARAM3 TYPE3 ... PARAMN TYPEN
PARAM is a name of test parameter and TYPE is it's type specification. It should be separated by any whitespace character.
Each test parameter type is defined by 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 which 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 following test parameters: ignore_case
, text_forbid
, text_require
, regex_forbid
, 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. You can put here some initalization. Report plugins can use this hook to create header of report.
end_tests ()
Called when test sequence is finished. You can put here some finialization code. Report plugins can use this hook to finish creation of report.
prepare_request ()
Called before HTTP::WebTest does HTTP request. Various properties of request here can be set here.
check_response ()
Called once HTTP::WebTest did HTTP request and have got HTTP response. Test checks should be placed here.
report_test ()
Called when HTTP::WebTest got HTTP response after <check_response> hooks. Normally used by report plugins to generate piece of report about test step just done.
Returns
This methods should return result of test checks made in following form:
[ [ TEST_GROUP1_NAME, TEST_RESULT1, TEST_RESULT2, ... ],
[ TEST_GROUP2_NAME, TEST_RESULT1, TEST_RESULT2, ... ],
...
];
TEST_GROUP_NAME
is a string which describes a group of test checks and their results. It is used during generation of test report.
TEST_RESULT
is an HTTP::WebTest::TestResult object.
EXAMPLES
Well, why anybody need examples when source code of all HTTP::WebTest plugins is available.
Some good examples are:
- HTTP::WebTest::Plugin::Cookies
-
Plugin which uses both
prepare_request
andcheck_response
hooks. - HTTP::WebTest::Plugin::StatusTest
-
Very simple plugin which defines only
check_response
hook. - HTTP::WebTest::Plugin::DefaultReport
-
Example of report plugin. Uses
start_tests
,report_test
andend_tests
hooks.
COPYRIGHT
Copyright (c) 2001,2002 Ilya Martynov. All rights reserved.
This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License.