Update of /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport/lib/HTTP/WebTest/Plugin
In directory sc8-pr-cvs1:/tmp/cvs-serv8507/lib/HTTP/WebTest/Plugin
Modified Files:
XMLReport.pm
Log Message:
Prepared for release, small fixes and more robust tests
Index: XMLReport.pm
===================================================================
RCS file: /cvsroot/http-webtest/HTTP-WebTest-Plugin-XMLReport/lib/HTTP/WebTest/Plugin/XMLReport.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** XMLReport.pm 26 Dec 2002 20:33:48 -0000 1.2
--- XMLReport.pm 2 Jan 2003 16:52:16 -0000 1.3
***************
*** 5,9 ****
use XML::Writer;
use vars qw($VERSION);
! $VERSION = '0.92';
=head1 NAME
--- 5,9 ----
use XML::Writer;
use vars qw($VERSION);
! $VERSION = '1.00';
=head1 NAME
***************
*** 13,24 ****
=head2 VERSION
! Pre release version 0.92 - $Revision$
! This is *ALPHA* software, which means that its interfaces
! and output format may change.
=head1 SYNOPSIS
! See L<HTTP::WebTest>, the section about plugins.
=head1 DESCRIPTION
--- 13,23 ----
=head2 VERSION
! version 1.00 - $Revision$
! Compatible with L<HTTP::WebTest|HTTP::WebTest> version 2.x API
=head1 SYNOPSIS
! See L<HTTP::WebTest|HTTP::WebTest>, the section about plugins.
=head1 DESCRIPTION
***************
*** 36,55 ****
<group name="Homepage" url="http://www.mysite.com">
<test name="Status code check">
! <result status="OK">200 OK</result>
</test>
<test name="Forbidden text">
! <result status="OK">Premature end of script headers</result>
</test>
<test name="Required text">
! <result status="OK">Please login:</result>
! <result status="OK"></html></result>
</test>
<test name="Content size check">
! <result status="OK">Number of returned bytes ( 30381 ) is > or = 10000 ?</result>
! <result status="OK">Number of returned bytes ( 30381 ) is < or = 99000 ?</result>
</test>
<test name="Response time check">
! <result status="OK">Response time ( 9.14 ) is > or = 0.01 ?</result>
! <result status="FAILED">Response time ( 9.14 ) is < or = 8.00 ?</result>
</test>
</group>
--- 35,54 ----
<group name="Homepage" url="http://www.mysite.com">
<test name="Status code check">
! <result status="PASS">200 OK</result>
</test>
<test name="Forbidden text">
! <result status="PASS">Premature end of script headers</result>
</test>
<test name="Required text">
! <result status="PASS">Please login:</result>
! <result status="PASS"></html></result>
</test>
<test name="Content size check">
! <result status="PASS">Number of returned bytes ( 30381 ) is > or = 10000 ?</result>
! <result status="PASS">Number of returned bytes ( 30381 ) is < or = 99000 ?</result>
</test>
<test name="Response time check">
! <result status="PASS">Response time ( 9.14 ) is > or = 0.01 ?</result>
! <result status="FAIL">Response time ( 9.14 ) is < or = 8.00 ?</result>
</test>
</group>
***************
*** 71,74 ****
--- 70,76 ----
xmllint --valid saved_xml_report.xml
+ (xmllint is a utility program that comes bundled with the Gnome
+ XML libraries, aka LibXML).
+
=head3 Allowed values
***************
*** 79,94 ****
C<no>
=head1 TEST PARAMETERS
! Note: these are set from the test definitions, see L<HTTP::WebTest>
for details.
! =head2 test_name, name
! Set C<test_name> from C<wtscript> or C<name> as the hash key from
! a test definition.
! Output as the C<name> attribute in for the C<group> element in the
! XML output document.
=head1 REPORT DTD
--- 81,117 ----
C<no>
+ =head2 default_report
+
+ You may want to suppress the default report.
+ From C<wtscript>:
+
+ default_report no
+
+ Or as optional global parameter from Perl:
+
+ $wt = new HTTP::WebTest($defs, { default_report => 'no' });
+
+ =head3 Allowed values
+
+ C<yes>, C<no>
+
+ =head3 Default value
+
+ C<yes>
+
+
=head1 TEST PARAMETERS
! Note: these are set from the test definitions, see L<HTTP::WebTest|HTTP::WebTest>
for details.
! =head2 test_name
! The C<test_name> attribute from C<wtscript> will be used for the
! C<name> attribute of the C<group> element in the XML output document.
! This attribute is the easiest way to identify each test group, so
! it is adviced that you define one unique name per group in the
! test definitions.
=head1 REPORT DTD
***************
*** 112,116 ****
<!ELEMENT result (#PCDATA)>
<!ATTLIST result
! status (OK | FAILED) #REQUIRED >
=cut
--- 135,139 ----
<!ELEMENT result (#PCDATA)>
<!ATTLIST result
! status (PASS | FAIL) #REQUIRED >
=cut
***************
*** 119,123 ****
return shift->SUPER::param_types . "\n" .
q(default_report yesno
! xml_report_dtd yesno
test_name scalar
);
--- 142,146 ----
return shift->SUPER::param_types . "\n" .
q(default_report yesno
! xml_report_dtd yesno
test_name scalar
);
***************
*** 139,143 ****
my $dtd = $self->global_test_param('xml_report_dtd');
if ($dtd && ($dtd eq 'yes')) {
! $dtd = "<!DOCTYPE testresults [\n" . join('', <DATA>) . "]>\n";
} else {
$dtd = undef;
--- 162,166 ----
my $dtd = $self->global_test_param('xml_report_dtd');
if ($dtd && ($dtd eq 'yes')) {
! $dtd = sprintf("<!DOCTYPE testresults [\n%s]>\n", &_DTD());
} else {
$dtd = undef;
***************
*** 153,170 ****
}
- ##FIXME: not sure if this will work...
- sub output_dtd {
- my $self = shift;
-
- $self->global_validate_params(qw(fh_out));
- my $fh_out = $self->global_test_param('fh_out');
- my $dtd = "<?xml version=\"1.0\" ?>\n" . join('', <DATA>);
- if ($fh_out) {
- $fh_out->print($dtd);
- } else {
- return $dtd;
- }
- }
-
sub start_tests {
my $self = shift;
--- 176,179 ----
***************
*** 183,188 ****
# get test params we handle
! my $test_name = $self->test_param('test_name');
! my $url = '';
if($self->webtest->current_request) {
$url = $self->webtest->current_request->uri;
--- 192,197 ----
# get test params we handle
! my $test_name = $self->test_param('test_name', 'untitled');
! my $url = '';
if($self->webtest->current_request) {
$url = $self->webtest->current_request->uri;
***************
*** 196,201 ****
for my $result (@{$self->webtest->current_results}) {
# test results
! my $group_comment = $$result[0];
! my @results = @$result[1 .. @$result - 1];
next unless @results;
--- 205,210 ----
for my $result (@{$self->webtest->current_results}) {
# test results
! my $group_comment = $$result[0] || '';
! my @results = @$result[1 .. @$result - 1];
next unless @results;
***************
*** 204,209 ****
for my $subresult (@$result[1 .. @$result - 1]) {
! my $comment = $subresult->comment;
! my $ok = $subresult->ok ? 'OK' : 'FAILED';
$self->{x_out}->dataElement('result', $comment, 'status' => $ok);
--- 213,218 ----
for my $subresult (@$result[1 .. @$result - 1]) {
! my $comment = $subresult->comment || '';
! my $ok = $subresult->ok ? 'PASS' : 'FAIL';
$self->{x_out}->dataElement('result', $comment, 'status' => $ok);
***************
*** 239,245 ****
}
! =head1 VERSION
- $Id$
=head1 COPYRIGHT
--- 248,293 ----
}
! sub _DTD {
! return <<"DTD";
! <!ELEMENT testresults (group+)>
! <!ATTLIST testresults
! date CDATA #REQUIRED >
!
! <!ELEMENT group (test+)>
! <!ATTLIST group
! name CDATA #REQUIRED
! url CDATA #REQUIRED >
!
! <!ELEMENT test (result+)>
! <!ATTLIST test
! name CDATA #REQUIRED >
!
! <!ELEMENT result (#PCDATA)>
! <!ATTLIST result
! status (PASS | FAIL) #REQUIRED >
! DTD
! }
!
! =head1 BUGS
!
! If the test run dies, the resulting XML report is not preperly
! terminated, resulting in malformed format which is not parsable
! by conforming XML processors.
!
! This can happen for example when a document could not be fetched
! and when subsequently a test with the Click plugin is used.
!
! The following limitations apply:
!
! These options from the DefaultReport are missing:
!
! show_headers
! show_html
! show_cookies
!
! Sending email from this module is not implemented; a work around
! would be to parse the resulting XML document and generate an
! email message whenever a test result has status C<FAIL>.
=head1 COPYRIGHT
***************
*** 266,284 ****
1;
- __DATA__
- <!ELEMENT testresults (group+)>
- <!ATTLIST testresults
- date CDATA #REQUIRED >
-
- <!ELEMENT group (test+)>
- <!ATTLIST group
- name CDATA #REQUIRED
- url CDATA #REQUIRED >
-
- <!ELEMENT test (result+)>
- <!ATTLIST test
- name CDATA #REQUIRED >
-
- <!ELEMENT result (#PCDATA)>
- <!ATTLIST result
- status (OK | FAILED) #REQUIRED >
--- 314,315 ----
|