line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: HarnessReport.pm,v 1.12 2003/03/02 11:52:09 m_ilya Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTTP::WebTest::Plugin::HarnessReport; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
HTTP::WebTest::Plugin::HarnessReport - Test::Harness compatible reports |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
N/A |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This plugin creates reports that are compatible with |
16
|
|
|
|
|
|
|
L. By default, this plugin is not loaded |
17
|
|
|
|
|
|
|
by L. To load it, use the global test |
18
|
|
|
|
|
|
|
parameter C. Internally this plugin uses |
19
|
|
|
|
|
|
|
L module so it should be compatible with |
20
|
|
|
|
|
|
|
other testing libraries (like L or |
21
|
|
|
|
|
|
|
L). You should be able to |
22
|
|
|
|
|
|
|
intermix them freely in one test script. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Unless you want to get mix of outputs from the default report and this |
25
|
|
|
|
|
|
|
report (normally you don't want it), the default report plugin should |
26
|
|
|
|
|
|
|
be disabled. See parameter C (value C). |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Test parameters C and C are documented in |
29
|
|
|
|
|
|
|
L. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 EXAMPLE |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
See L for example. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
5
|
use base qw(HTTP::WebTest::Plugin); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
119
|
|
40
|
1
|
|
|
1
|
|
7
|
use HTTP::WebTest::Utils qw(make_access_method); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11670
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
13
|
use Test::Builder; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
557
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 TEST PARAMETERS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
None. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $TEST = Test::Builder->new; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# declare supported test params |
53
|
|
|
|
|
|
|
sub param_types { |
54
|
5
|
|
|
5
|
1
|
44
|
return q(test_name scalar); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub report_test { |
58
|
5
|
|
|
5
|
0
|
10
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
5
|
|
|
|
|
9
|
my @results = @{$self->webtest->current_test->results}; |
|
5
|
|
|
|
|
21
|
|
61
|
|
|
|
|
|
|
|
62
|
5
|
|
|
|
|
24
|
$self->validate_params(qw(test_name)); |
63
|
|
|
|
|
|
|
|
64
|
5
|
|
|
|
|
17
|
my $test_name = $self->test_param('test_name'); |
65
|
5
|
|
|
|
|
8
|
my $url = 'N/A'; |
66
|
5
|
50
|
|
|
|
18
|
if($self->webtest->current_request) { |
67
|
5
|
|
|
|
|
16
|
$url = $self->webtest->current_request->uri; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# fool Test::Builder to generate diag output on STDOUT |
71
|
5
|
|
|
|
|
41
|
my $failure_output = $TEST->failure_output; |
72
|
5
|
|
|
|
|
51
|
$TEST->failure_output($TEST->output); |
73
|
|
|
|
|
|
|
|
74
|
5
|
|
|
|
|
155
|
$TEST->diag('-' x 60); |
75
|
5
|
|
|
|
|
807
|
$TEST->diag("URL: $url"); |
76
|
5
|
100
|
|
|
|
431
|
$TEST->diag("Test Name: $test_name") if defined $test_name; |
77
|
|
|
|
|
|
|
|
78
|
5
|
|
|
|
|
78
|
my $all_ok = 1; |
79
|
|
|
|
|
|
|
|
80
|
5
|
|
|
|
|
8
|
for my $result (@{$self->webtest->current_results}) { |
|
5
|
|
|
|
|
20
|
|
81
|
|
|
|
|
|
|
# test results |
82
|
8
|
|
|
|
|
243
|
my $group_comment = $$result[0]; |
83
|
|
|
|
|
|
|
|
84
|
8
|
|
|
|
|
30
|
my @results = @$result[1 .. @$result - 1]; |
85
|
|
|
|
|
|
|
|
86
|
8
|
|
|
|
|
37
|
$TEST->diag(uc($group_comment)); |
87
|
|
|
|
|
|
|
|
88
|
8
|
|
|
|
|
747
|
for my $subresult (@$result[1 .. @$result - 1]) { |
89
|
8
|
|
|
|
|
28
|
my $comment = $subresult->comment; |
90
|
8
|
100
|
|
|
|
30
|
my $ok = $subresult->ok ? 'SUCCEED' : 'FAIL'; |
91
|
8
|
|
66
|
|
|
41
|
$all_ok &&= $subresult->ok; |
92
|
|
|
|
|
|
|
|
93
|
8
|
|
|
|
|
36
|
$TEST->diag(" $comment: $ok\n"); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# restore failure_output |
98
|
5
|
|
|
|
|
419
|
$TEST->failure_output($failure_output); |
99
|
|
|
|
|
|
|
|
100
|
5
|
|
|
|
|
146
|
local $Test::Builder::Level = 3; |
101
|
5
|
|
|
|
|
25
|
$TEST->ok($all_ok); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
109
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 SEE ALSO |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
L |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |