| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::FITesque; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
90671
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
79
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
83
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use base qw(Exporter); |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
279
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(run_tests suite test); |
|
8
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
|
9
|
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1172
|
use Test::FITesque::Test; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
66
|
|
|
11
|
2
|
|
|
2
|
|
2499
|
use Test::FITesque::Suite; |
|
|
2
|
|
|
|
|
44
|
|
|
|
2
|
|
|
|
|
867
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Test::FITesque - the FITesque framework! |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.03 |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
L is a framework designed to emulate the FIT L |
|
28
|
|
|
|
|
|
|
framework, but with a more perlish touch. While it is possible to use the FIT |
|
29
|
|
|
|
|
|
|
framework from within perl, it has a lot of unnessecary overhead related to its |
|
30
|
|
|
|
|
|
|
origins in the Java world. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
I created L for the following reasons: |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item * |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
I wanted to store my fixture tables in whatever format i wanted (JSON, YAML, Storable, etc) |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
I wanted to simplify the execution process to make it very transparent. I have |
|
43
|
|
|
|
|
|
|
used FitNesse up to this point along with the perl server, but found that |
|
44
|
|
|
|
|
|
|
the java framework was painful to debug and overly complex for the task it |
|
45
|
|
|
|
|
|
|
needed to achieve. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
I wanted to use the normal perl testing tools and utilities to fit my workflow |
|
50
|
|
|
|
|
|
|
more closely. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
I also wanted to be able to save the TAP output to more easily capture test |
|
55
|
|
|
|
|
|
|
results over time to track regressions and problematic tests. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 INTRODUCTION |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
FITesque starts with creating FITesque fixtures which are simply packages which |
|
62
|
|
|
|
|
|
|
allow for the creation of objects upon which methods can be called. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
package MyApp::Test::Fixture; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use strict; |
|
67
|
|
|
|
|
|
|
use warnings; |
|
68
|
|
|
|
|
|
|
use base qw(Test::FITesque::Fixture); |
|
69
|
|
|
|
|
|
|
use Test::More; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
file_exists : Test { |
|
72
|
|
|
|
|
|
|
my ($self, $file) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
ok -e $file, qq{File '$file' exists}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This simple fixture can now be run with a very basic and simple test. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $test = Test::FITesque::Test->new({ |
|
80
|
|
|
|
|
|
|
data => [ |
|
81
|
|
|
|
|
|
|
['MyApp::Test::Fixture'], |
|
82
|
|
|
|
|
|
|
['file_exists', '/etc/hosts'] |
|
83
|
|
|
|
|
|
|
] |
|
84
|
|
|
|
|
|
|
}); |
|
85
|
|
|
|
|
|
|
$test->run_tests(); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The data option is simply a table of data to use when executing the fixture |
|
89
|
|
|
|
|
|
|
test. The first row must refer to the name of the L |
|
90
|
|
|
|
|
|
|
based fixture you wish to execute (like MyApp::Test::Fixture above). Any |
|
91
|
|
|
|
|
|
|
other cells in this row will be passed to the new() method on the Fixture |
|
92
|
|
|
|
|
|
|
class. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The following rows are all method calls on an instance of the Fixture |
|
95
|
|
|
|
|
|
|
class. This first cell must refer to a method name in the Fixture class, |
|
96
|
|
|
|
|
|
|
all following cells will be passed to the methods as arguments. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The run_tests() method on the FITesque test will simply run these methods |
|
99
|
|
|
|
|
|
|
in the order specified while taking care of maintaing TAP test count |
|
100
|
|
|
|
|
|
|
and the like underneath. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
If you have more than one instance of a test to run, you can add it to a |
|
103
|
|
|
|
|
|
|
suite. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
my $suite = Test::FITesque::Suite->new({ |
|
106
|
|
|
|
|
|
|
data => [$test1, $test2, $test3] |
|
107
|
|
|
|
|
|
|
}); |
|
108
|
|
|
|
|
|
|
$suite->run_tests(); |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This will also allow you to run test fixtures in a more dynamic fashion |
|
111
|
|
|
|
|
|
|
while still taking care of TAP test count. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Suites can not only take a list of tests to run, but also suites themselves. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The L package also supplies some handy helper functions |
|
116
|
|
|
|
|
|
|
to wrap most of the logic up for you. Please see the SYNOPSIS below for |
|
117
|
|
|
|
|
|
|
more information. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use Test::FITesque; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
run_tests { |
|
124
|
|
|
|
|
|
|
suite { ... }, |
|
125
|
|
|
|
|
|
|
test { |
|
126
|
|
|
|
|
|
|
['MyApp::Test::Fixture'], |
|
127
|
|
|
|
|
|
|
['file_exists', '/etc/hosts'] |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
}; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 EXPORTED FUNCTIONS |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 test |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
test { |
|
136
|
|
|
|
|
|
|
['Fixture::Class'], |
|
137
|
|
|
|
|
|
|
['divides', qw(8 4 2)], |
|
138
|
|
|
|
|
|
|
['multiplies', qw(5 6 30)], |
|
139
|
|
|
|
|
|
|
['adds', qw(4 3 7)], |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This function will return a L object. It takes a coderef |
|
143
|
|
|
|
|
|
|
which returns a list of array references of which the first must refer to your |
|
144
|
|
|
|
|
|
|
FITesque fixture. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub test (&@) { |
|
149
|
4
|
|
|
4
|
1
|
18
|
my $coderef = shift; |
|
150
|
4
|
|
|
|
|
12
|
my (@results) = $coderef->(); |
|
151
|
|
|
|
|
|
|
|
|
152
|
4
|
|
|
|
|
48
|
my $test = Test::FITesque::Test->new({ data => \@results }); |
|
153
|
4
|
|
|
|
|
17
|
return $test; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 suite |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
suite { |
|
159
|
|
|
|
|
|
|
test { |
|
160
|
|
|
|
|
|
|
... |
|
161
|
|
|
|
|
|
|
}, |
|
162
|
|
|
|
|
|
|
test { |
|
163
|
|
|
|
|
|
|
... |
|
164
|
|
|
|
|
|
|
}, |
|
165
|
|
|
|
|
|
|
suite { |
|
166
|
|
|
|
|
|
|
test { |
|
167
|
|
|
|
|
|
|
... |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
}, |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
This function will return a L object. It takes a coderef |
|
173
|
|
|
|
|
|
|
which returns a list of L objects or/and |
|
174
|
|
|
|
|
|
|
L objects. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub suite (&@) { |
|
179
|
1
|
|
|
1
|
1
|
8
|
my $coderef = shift; |
|
180
|
1
|
|
|
|
|
5
|
my @results = $coderef->(); |
|
181
|
|
|
|
|
|
|
|
|
182
|
1
|
|
|
|
|
15
|
my $suite = Test::FITesque::Suite->new({ data => \@results }); |
|
183
|
1
|
|
|
|
|
8
|
return $suite; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 run_tests |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
run_tests { |
|
189
|
|
|
|
|
|
|
suite { |
|
190
|
|
|
|
|
|
|
... |
|
191
|
|
|
|
|
|
|
}, |
|
192
|
|
|
|
|
|
|
test { |
|
193
|
|
|
|
|
|
|
... |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This function takes a coderef of suite and/or test objects. This will then |
|
198
|
|
|
|
|
|
|
wrap these all into a suite and call L's L |
|
199
|
|
|
|
|
|
|
method. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub run_tests (&@) { |
|
204
|
2
|
|
|
2
|
1
|
1143
|
my $coderef = shift; |
|
205
|
2
|
|
|
|
|
9
|
my @results = $coderef->(); |
|
206
|
|
|
|
|
|
|
|
|
207
|
2
|
|
|
|
|
7
|
my $tester; |
|
208
|
2
|
100
|
|
|
|
8
|
if(@results > 1){ |
|
209
|
1
|
|
|
|
|
5
|
$tester = Test::FITesque::Suite->new({ data => \@results }); |
|
210
|
|
|
|
|
|
|
} else { |
|
211
|
1
|
|
|
|
|
2
|
$tester = shift @results; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
2
|
|
|
|
|
9
|
$tester->run_tests; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
L, L, L |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 TEST COVERAGE |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
This distribution is heavily unit and system tested for compatability with |
|
224
|
|
|
|
|
|
|
L. If you come across any bugs, please send me or submit failing |
|
225
|
|
|
|
|
|
|
tests to Test-FITesques RT queue. Please see the 'SUPPORT' section below on |
|
226
|
|
|
|
|
|
|
how to supply these. |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
|
229
|
|
|
|
|
|
|
File stmt bran cond sub pod time total |
|
230
|
|
|
|
|
|
|
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
|
231
|
|
|
|
|
|
|
blib/lib/Test/FITesque.pm 100.0 100.0 n/a 100.0 100.0 5.2 100.0 |
|
232
|
|
|
|
|
|
|
.../Test/FITesque/Fixture.pm 100.0 100.0 100.0 100.0 100.0 29.1 100.0 |
|
233
|
|
|
|
|
|
|
...ib/Test/FITesque/Suite.pm 100.0 100.0 100.0 100.0 100.0 14.6 100.0 |
|
234
|
|
|
|
|
|
|
...lib/Test/FITesque/Test.pm 100.0 100.0 100.0 100.0 100.0 51.1 100.0 |
|
235
|
|
|
|
|
|
|
Total 100.0 100.0 100.0 100.0 100.0 100.0 100.0 |
|
236
|
|
|
|
|
|
|
---------------------------- ------ ------ ------ ------ ------ ------ ------ |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 AUTHOR |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Scott McWhirter, C<< >> |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 TODO |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=over |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item * |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Add more documentation |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item * |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Add some cookbook examples |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item * |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Look at some of the Fixture base class code to see if it can be restructured to |
|
257
|
|
|
|
|
|
|
allow for more evil coderef support. |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item * |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Update code to take advantage of newer Test::Harness/Test::Builder features. |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=back |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 BUGS |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
268
|
|
|
|
|
|
|
C, or through the web interface at |
|
269
|
|
|
|
|
|
|
L. |
|
270
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
271
|
|
|
|
|
|
|
your bug as I make changes. |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 LIMITATIONS |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Due to limitations in the TAP protocol and perl's TAP tools such as |
|
276
|
|
|
|
|
|
|
L, all Fixture tables have to be held in memory. It also means |
|
277
|
|
|
|
|
|
|
that Fixture tables cannot be treated as a stream so there is no easy way |
|
278
|
|
|
|
|
|
|
to seperate out which tables output is which. To remedy this, I suggest that |
|
279
|
|
|
|
|
|
|
you pass a 'name' parameter to the Fixture classes constructor and print this |
|
280
|
|
|
|
|
|
|
to screen or use the diag() function from L. |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 SUPPORT |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
perldoc Test::FITesque |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
You can also look for information at: |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=over 4 |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
L |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
L |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
L |
|
303
|
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=item * Search CPAN |
|
305
|
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
L |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=back |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Copyright 2007 Scott McWhirter, all rights reserved. |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
This program is released under the following license: BSD. Please see the |
|
315
|
|
|
|
|
|
|
LICENSE file included in this distribution for details. |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=cut |
|
318
|
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
1; # End of Test::FITesque |