Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "Test::More 3" | |
132 | .TH Test::More 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | Test::More \- yet another framework for writing test scripts | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 5 | |
138 | \& use Test::More tests => $Num_Tests; | |
139 | \& # or | |
140 | \& use Test::More qw(no_plan); | |
141 | \& # or | |
142 | \& use Test::More skip_all => $reason; | |
143 | .Ve | |
144 | .PP | |
145 | .Vb 2 | |
146 | \& BEGIN { use_ok( 'Some::Module' ); } | |
147 | \& require_ok( 'Some::Module' ); | |
148 | .Ve | |
149 | .PP | |
150 | .Vb 2 | |
151 | \& # Various ways to say "ok" | |
152 | \& ok($this eq $that, $test_name); | |
153 | .Ve | |
154 | .PP | |
155 | .Vb 2 | |
156 | \& is ($this, $that, $test_name); | |
157 | \& isnt($this, $that, $test_name); | |
158 | .Ve | |
159 | .PP | |
160 | .Vb 2 | |
161 | \& # Rather than print STDERR "# here's what went wrong\en" | |
162 | \& diag("here's what went wrong"); | |
163 | .Ve | |
164 | .PP | |
165 | .Vb 2 | |
166 | \& like ($this, qr/that/, $test_name); | |
167 | \& unlike($this, qr/that/, $test_name); | |
168 | .Ve | |
169 | .PP | |
170 | .Vb 1 | |
171 | \& cmp_ok($this, '==', $that, $test_name); | |
172 | .Ve | |
173 | .PP | |
174 | .Vb 1 | |
175 | \& is_deeply($complex_structure1, $complex_structure2, $test_name); | |
176 | .Ve | |
177 | .PP | |
178 | .Vb 2 | |
179 | \& SKIP: { | |
180 | \& skip $why, $how_many unless $have_some_feature; | |
181 | .Ve | |
182 | .PP | |
183 | .Vb 3 | |
184 | \& ok( foo(), $test_name ); | |
185 | \& is( foo(42), 23, $test_name ); | |
186 | \& }; | |
187 | .Ve | |
188 | .PP | |
189 | .Vb 2 | |
190 | \& TODO: { | |
191 | \& local $TODO = $why; | |
192 | .Ve | |
193 | .PP | |
194 | .Vb 3 | |
195 | \& ok( foo(), $test_name ); | |
196 | \& is( foo(42), 23, $test_name ); | |
197 | \& }; | |
198 | .Ve | |
199 | .PP | |
200 | .Vb 2 | |
201 | \& can_ok($module, @methods); | |
202 | \& isa_ok($object, $class); | |
203 | .Ve | |
204 | .PP | |
205 | .Vb 2 | |
206 | \& pass($test_name); | |
207 | \& fail($test_name); | |
208 | .Ve | |
209 | .PP | |
210 | .Vb 1 | |
211 | \& BAIL_OUT($why); | |
212 | .Ve | |
213 | .PP | |
214 | .Vb 2 | |
215 | \& # UNIMPLEMENTED!!! | |
216 | \& my @status = Test::More::status; | |
217 | .Ve | |
218 | .SH "DESCRIPTION" | |
219 | .IX Header "DESCRIPTION" | |
220 | \&\fB\s-1STOP\s0!\fR If you're just getting started writing tests, have a look at | |
221 | Test::Simple first. This is a drop in replacement for Test::Simple | |
222 | which you can switch to once you get the hang of basic testing. | |
223 | .PP | |
224 | The purpose of this module is to provide a wide range of testing | |
225 | utilities. Various ways to say \*(L"ok\*(R" with better diagnostics, | |
226 | facilities to skip tests, test future features and compare complicated | |
227 | data structures. While you can do almost anything with a simple | |
228 | \&\f(CW\*(C`ok()\*(C'\fR function, it doesn't provide good diagnostic output. | |
229 | .Sh "I love it when a plan comes together" | |
230 | .IX Subsection "I love it when a plan comes together" | |
231 | Before anything else, you need a testing plan. This basically declares | |
232 | how many tests your script is going to run to protect against premature | |
233 | failure. | |
234 | .PP | |
235 | The preferred way to do this is to declare a plan when you \f(CW\*(C`use Test::More\*(C'\fR. | |
236 | .PP | |
237 | .Vb 1 | |
238 | \& use Test::More tests => $Num_Tests; | |
239 | .Ve | |
240 | .PP | |
241 | There are rare cases when you will not know beforehand how many tests | |
242 | your script is going to run. In this case, you can declare that you | |
243 | have no plan. (Try to avoid using this as it weakens your test.) | |
244 | .PP | |
245 | .Vb 1 | |
246 | \& use Test::More qw(no_plan); | |
247 | .Ve | |
248 | .PP | |
249 | \&\fB\s-1NOTE\s0\fR: using no_plan requires a Test::Harness upgrade else it will | |
250 | think everything has failed. See \*(L"\s-1CAVEATS\s0 and \s-1NOTES\s0\*(R"). | |
251 | .PP | |
252 | In some cases, you'll want to completely skip an entire testing script. | |
253 | .PP | |
254 | .Vb 1 | |
255 | \& use Test::More skip_all => $skip_reason; | |
256 | .Ve | |
257 | .PP | |
258 | Your script will declare a skip with the reason why you skipped and | |
259 | exit immediately with a zero (success). See Test::Harness for | |
260 | details. | |
261 | .PP | |
262 | If you want to control what functions Test::More will export, you | |
263 | have to use the 'import' option. For example, to import everything | |
264 | but 'fail', you'd do: | |
265 | .PP | |
266 | .Vb 1 | |
267 | \& use Test::More tests => 23, import => ['!fail']; | |
268 | .Ve | |
269 | .PP | |
270 | Alternatively, you can use the \fIplan()\fR function. Useful for when you | |
271 | have to calculate the number of tests. | |
272 | .PP | |
273 | .Vb 2 | |
274 | \& use Test::More; | |
275 | \& plan tests => keys %Stuff * 3; | |
276 | .Ve | |
277 | .PP | |
278 | or for deciding between running the tests at all: | |
279 | .PP | |
280 | .Vb 7 | |
281 | \& use Test::More; | |
282 | \& if( $^O eq 'MacOS' ) { | |
283 | \& plan skip_all => 'Test irrelevant on MacOS'; | |
284 | \& } | |
285 | \& else { | |
286 | \& plan tests => 42; | |
287 | \& } | |
288 | .Ve | |
289 | .Sh "Test names" | |
290 | .IX Subsection "Test names" | |
291 | By convention, each test is assigned a number in order. This is | |
292 | largely done automatically for you. However, it's often very useful to | |
293 | assign a name to each test. Which would you rather see: | |
294 | .PP | |
295 | .Vb 3 | |
296 | \& ok 4 | |
297 | \& not ok 5 | |
298 | \& ok 6 | |
299 | .Ve | |
300 | .PP | |
301 | or | |
302 | .PP | |
303 | .Vb 3 | |
304 | \& ok 4 - basic multi-variable | |
305 | \& not ok 5 - simple exponential | |
306 | \& ok 6 - force == mass * acceleration | |
307 | .Ve | |
308 | .PP | |
309 | The later gives you some idea of what failed. It also makes it easier | |
310 | to find the test in your script, simply search for \*(L"simple | |
311 | exponential\*(R". | |
312 | .PP | |
313 | All test functions take a name argument. It's optional, but highly | |
314 | suggested that you use it. | |
315 | .Sh "I'm ok, you're not ok." | |
316 | .IX Subsection "I'm ok, you're not ok." | |
317 | The basic purpose of this module is to print out either \*(L"ok #\*(R" or \*(L"not | |
318 | ok #\*(R" depending on if a given test succeeded or failed. Everything | |
319 | else is just gravy. | |
320 | .PP | |
321 | All of the following print \*(L"ok\*(R" or \*(L"not ok\*(R" depending on if the test | |
322 | succeeded or failed. They all also return true or false, | |
323 | respectively. | |
324 | .IP "\fBok\fR" 4 | |
325 | .IX Item "ok" | |
326 | .Vb 1 | |
327 | \& ok($this eq $that, $test_name); | |
328 | .Ve | |
329 | .Sp | |
330 | This simply evaluates any expression (\f(CW\*(C`$this eq $that\*(C'\fR is just a | |
331 | simple example) and uses that to determine if the test succeeded or | |
332 | failed. A true expression passes, a false one fails. Very simple. | |
333 | .Sp | |
334 | For example: | |
335 | .Sp | |
336 | .Vb 4 | |
337 | \& ok( $exp{9} == 81, 'simple exponential' ); | |
338 | \& ok( Film->can('db_Main'), 'set_db()' ); | |
339 | \& ok( $p->tests == 4, 'saw tests' ); | |
340 | \& ok( !grep !defined $_, @items, 'items populated' ); | |
341 | .Ve | |
342 | .Sp | |
343 | (Mnemonic: \*(L"This is ok.\*(R") | |
344 | .Sp | |
345 | $test_name is a very short description of the test that will be printed | |
346 | out. It makes it very easy to find a test in your script when it fails | |
347 | and gives others an idea of your intentions. \f(CW$test_name\fR is optional, | |
348 | but we \fBvery\fR strongly encourage its use. | |
349 | .Sp | |
350 | Should an \fIok()\fR fail, it will produce some diagnostics: | |
351 | .Sp | |
352 | .Vb 3 | |
353 | \& not ok 18 - sufficient mucus | |
354 | \& # Failed test 'sufficient mucus' | |
355 | \& # in foo.t at line 42. | |
356 | .Ve | |
357 | .Sp | |
358 | This is actually Test::Simple's \fIok()\fR routine. | |
359 | .IP "\fBis\fR" 4 | |
360 | .IX Item "is" | |
361 | .PD 0 | |
362 | .IP "\fBisnt\fR" 4 | |
363 | .IX Item "isnt" | |
364 | .PD | |
365 | .Vb 2 | |
366 | \& is ( $this, $that, $test_name ); | |
367 | \& isnt( $this, $that, $test_name ); | |
368 | .Ve | |
369 | .Sp | |
370 | Similar to \fIok()\fR, \fIis()\fR and \fIisnt()\fR compare their two arguments | |
371 | with \f(CW\*(C`eq\*(C'\fR and \f(CW\*(C`ne\*(C'\fR respectively and use the result of that to | |
372 | determine if the test succeeded or failed. So these: | |
373 | .Sp | |
374 | .Vb 2 | |
375 | \& # Is the ultimate answer 42? | |
376 | \& is( ultimate_answer(), 42, "Meaning of Life" ); | |
377 | .Ve | |
378 | .Sp | |
379 | .Vb 2 | |
380 | \& # $foo isn't empty | |
381 | \& isnt( $foo, '', "Got some foo" ); | |
382 | .Ve | |
383 | .Sp | |
384 | are similar to these: | |
385 | .Sp | |
386 | .Vb 2 | |
387 | \& ok( ultimate_answer() eq 42, "Meaning of Life" ); | |
388 | \& ok( $foo ne '', "Got some foo" ); | |
389 | .Ve | |
390 | .Sp | |
391 | (Mnemonic: \*(L"This is that.\*(R" \*(L"This isn't that.\*(R") | |
392 | .Sp | |
393 | So why use these? They produce better diagnostics on failure. \fIok()\fR | |
394 | cannot know what you are testing for (beyond the name), but \fIis()\fR and | |
395 | \&\fIisnt()\fR know what the test was and why it failed. For example this | |
396 | test: | |
397 | .Sp | |
398 | .Vb 2 | |
399 | \& my $foo = 'waffle'; my $bar = 'yarblokos'; | |
400 | \& is( $foo, $bar, 'Is foo the same as bar?' ); | |
401 | .Ve | |
402 | .Sp | |
403 | Will produce something like this: | |
404 | .Sp | |
405 | .Vb 5 | |
406 | \& not ok 17 - Is foo the same as bar? | |
407 | \& # Failed test 'Is foo the same as bar?' | |
408 | \& # in foo.t at line 139. | |
409 | \& # got: 'waffle' | |
410 | \& # expected: 'yarblokos' | |
411 | .Ve | |
412 | .Sp | |
413 | So you can figure out what went wrong without rerunning the test. | |
414 | .Sp | |
415 | You are encouraged to use \fIis()\fR and \fIisnt()\fR over \fIok()\fR where possible, | |
416 | however do not be tempted to use them to find out if something is | |
417 | true or false! | |
418 | .Sp | |
419 | .Vb 2 | |
420 | \& # XXX BAD! | |
421 | \& is( exists $brooklyn{tree}, 1, 'A tree grows in Brooklyn' ); | |
422 | .Ve | |
423 | .Sp | |
424 | This does not check if \f(CW\*(C`exists $brooklyn{tree}\*(C'\fR is true, it checks if | |
425 | it returns 1. Very different. Similar caveats exist for false and 0. | |
426 | In these cases, use \fIok()\fR. | |
427 | .Sp | |
428 | .Vb 1 | |
429 | \& ok( exists $brooklyn{tree}, 'A tree grows in Brooklyn' ); | |
430 | .Ve | |
431 | .Sp | |
432 | For those grammatical pedants out there, there's an \f(CW\*(C`isn't()\*(C'\fR | |
433 | function which is an alias of \fIisnt()\fR. | |
434 | .IP "\fBlike\fR" 4 | |
435 | .IX Item "like" | |
436 | .Vb 1 | |
437 | \& like( $this, qr/that/, $test_name ); | |
438 | .Ve | |
439 | .Sp | |
440 | Similar to \fIok()\fR, \fIlike()\fR matches \f(CW$this\fR against the regex \f(CW\*(C`qr/that/\*(C'\fR. | |
441 | .Sp | |
442 | So this: | |
443 | .Sp | |
444 | .Vb 1 | |
445 | \& like($this, qr/that/, 'this is like that'); | |
446 | .Ve | |
447 | .Sp | |
448 | is similar to: | |
449 | .Sp | |
450 | .Vb 1 | |
451 | \& ok( $this =~ /that/, 'this is like that'); | |
452 | .Ve | |
453 | .Sp | |
454 | (Mnemonic \*(L"This is like that\*(R".) | |
455 | .Sp | |
456 | The second argument is a regular expression. It may be given as a | |
457 | regex reference (i.e. \f(CW\*(C`qr//\*(C'\fR) or (for better compatibility with older | |
458 | perls) as a string that looks like a regex (alternative delimiters are | |
459 | currently not supported): | |
460 | .Sp | |
461 | .Vb 1 | |
462 | \& like( $this, '/that/', 'this is like that' ); | |
463 | .Ve | |
464 | .Sp | |
465 | Regex options may be placed on the end (\f(CW'/that/i'\fR). | |
466 | .Sp | |
467 | Its advantages over \fIok()\fR are similar to that of \fIis()\fR and \fIisnt()\fR. Better | |
468 | diagnostics on failure. | |
469 | .IP "\fBunlike\fR" 4 | |
470 | .IX Item "unlike" | |
471 | .Vb 1 | |
472 | \& unlike( $this, qr/that/, $test_name ); | |
473 | .Ve | |
474 | .Sp | |
475 | Works exactly as \fIlike()\fR, only it checks if \f(CW$this\fR \fBdoes not\fR match the | |
476 | given pattern. | |
477 | .IP "\fBcmp_ok\fR" 4 | |
478 | .IX Item "cmp_ok" | |
479 | .Vb 1 | |
480 | \& cmp_ok( $this, $op, $that, $test_name ); | |
481 | .Ve | |
482 | .Sp | |
483 | Halfway between \fIok()\fR and \fIis()\fR lies \fIcmp_ok()\fR. This allows you to | |
484 | compare two arguments using any binary perl operator. | |
485 | .Sp | |
486 | .Vb 2 | |
487 | \& # ok( $this eq $that ); | |
488 | \& cmp_ok( $this, 'eq', $that, 'this eq that' ); | |
489 | .Ve | |
490 | .Sp | |
491 | .Vb 2 | |
492 | \& # ok( $this == $that ); | |
493 | \& cmp_ok( $this, '==', $that, 'this == that' ); | |
494 | .Ve | |
495 | .Sp | |
496 | .Vb 3 | |
497 | \& # ok( $this && $that ); | |
498 | \& cmp_ok( $this, '&&', $that, 'this && that' ); | |
499 | \& ...etc... | |
500 | .Ve | |
501 | .Sp | |
502 | Its advantage over \fIok()\fR is when the test fails you'll know what \f(CW$this\fR | |
503 | and \f(CW$that\fR were: | |
504 | .Sp | |
505 | .Vb 5 | |
506 | \& not ok 1 | |
507 | \& # Failed test in foo.t at line 12. | |
508 | \& # '23' | |
509 | \& # && | |
510 | \& # undef | |
511 | .Ve | |
512 | .Sp | |
513 | It's also useful in those cases where you are comparing numbers and | |
514 | \&\fIis()\fR's use of \f(CW\*(C`eq\*(C'\fR will interfere: | |
515 | .Sp | |
516 | .Vb 1 | |
517 | \& cmp_ok( $big_hairy_number, '==', $another_big_hairy_number ); | |
518 | .Ve | |
519 | .IP "\fBcan_ok\fR" 4 | |
520 | .IX Item "can_ok" | |
521 | .Vb 2 | |
522 | \& can_ok($module, @methods); | |
523 | \& can_ok($object, @methods); | |
524 | .Ve | |
525 | .Sp | |
526 | Checks to make sure the \f(CW$module\fR or \f(CW$object\fR can do these \f(CW@methods\fR | |
527 | (works with functions, too). | |
528 | .Sp | |
529 | .Vb 1 | |
530 | \& can_ok('Foo', qw(this that whatever)); | |
531 | .Ve | |
532 | .Sp | |
533 | is almost exactly like saying: | |
534 | .Sp | |
535 | .Vb 4 | |
536 | \& ok( Foo->can('this') && | |
537 | \& Foo->can('that') && | |
538 | \& Foo->can('whatever') | |
539 | \& ); | |
540 | .Ve | |
541 | .Sp | |
542 | only without all the typing and with a better interface. Handy for | |
543 | quickly testing an interface. | |
544 | .Sp | |
545 | No matter how many \f(CW@methods\fR you check, a single \fIcan_ok()\fR call counts | |
546 | as one test. If you desire otherwise, use: | |
547 | .Sp | |
548 | .Vb 3 | |
549 | \& foreach my $meth (@methods) { | |
550 | \& can_ok('Foo', $meth); | |
551 | \& } | |
552 | .Ve | |
553 | .IP "\fBisa_ok\fR" 4 | |
554 | .IX Item "isa_ok" | |
555 | .Vb 2 | |
556 | \& isa_ok($object, $class, $object_name); | |
557 | \& isa_ok($ref, $type, $ref_name); | |
558 | .Ve | |
559 | .Sp | |
560 | Checks to see if the given \f(CW\*(C`$object\->isa($class)\*(C'\fR. Also checks to make | |
561 | sure the object was defined in the first place. Handy for this sort | |
562 | of thing: | |
563 | .Sp | |
564 | .Vb 2 | |
565 | \& my $obj = Some::Module->new; | |
566 | \& isa_ok( $obj, 'Some::Module' ); | |
567 | .Ve | |
568 | .Sp | |
569 | where you'd otherwise have to write | |
570 | .Sp | |
571 | .Vb 2 | |
572 | \& my $obj = Some::Module->new; | |
573 | \& ok( defined $obj && $obj->isa('Some::Module') ); | |
574 | .Ve | |
575 | .Sp | |
576 | to safeguard against your test script blowing up. | |
577 | .Sp | |
578 | It works on references, too: | |
579 | .Sp | |
580 | .Vb 1 | |
581 | \& isa_ok( $array_ref, 'ARRAY' ); | |
582 | .Ve | |
583 | .Sp | |
584 | The diagnostics of this test normally just refer to 'the object'. If | |
585 | you'd like them to be more specific, you can supply an \f(CW$object_name\fR | |
586 | (for example 'Test customer'). | |
587 | .IP "\fBpass\fR" 4 | |
588 | .IX Item "pass" | |
589 | .PD 0 | |
590 | .IP "\fBfail\fR" 4 | |
591 | .IX Item "fail" | |
592 | .PD | |
593 | .Vb 2 | |
594 | \& pass($test_name); | |
595 | \& fail($test_name); | |
596 | .Ve | |
597 | .Sp | |
598 | Sometimes you just want to say that the tests have passed. Usually | |
599 | the case is you've got some complicated condition that is difficult to | |
600 | wedge into an \fIok()\fR. In this case, you can simply use \fIpass()\fR (to | |
601 | declare the test ok) or fail (for not ok). They are synonyms for | |
602 | \&\fIok\fR\|(1) and \fIok\fR\|(0). | |
603 | .Sp | |
604 | Use these very, very, very sparingly. | |
605 | .Sh "Module tests" | |
606 | .IX Subsection "Module tests" | |
607 | You usually want to test if the module you're testing loads ok, rather | |
608 | than just vomiting if its load fails. For such purposes we have | |
609 | \&\f(CW\*(C`use_ok\*(C'\fR and \f(CW\*(C`require_ok\*(C'\fR. | |
610 | .IP "\fBuse_ok\fR" 4 | |
611 | .IX Item "use_ok" | |
612 | .Vb 2 | |
613 | \& BEGIN { use_ok($module); } | |
614 | \& BEGIN { use_ok($module, @imports); } | |
615 | .Ve | |
616 | .Sp | |
617 | These simply use the given \f(CW$module\fR and test to make sure the load | |
618 | happened ok. It's recommended that you run \fIuse_ok()\fR inside a \s-1BEGIN\s0 | |
619 | block so its functions are exported at compile-time and prototypes are | |
620 | properly honored. | |
621 | .Sp | |
622 | If \f(CW@imports\fR are given, they are passed through to the use. So this: | |
623 | .Sp | |
624 | .Vb 1 | |
625 | \& BEGIN { use_ok('Some::Module', qw(foo bar)) } | |
626 | .Ve | |
627 | .Sp | |
628 | is like doing this: | |
629 | .Sp | |
630 | .Vb 1 | |
631 | \& use Some::Module qw(foo bar); | |
632 | .Ve | |
633 | .Sp | |
634 | Version numbers can be checked like so: | |
635 | .Sp | |
636 | .Vb 2 | |
637 | \& # Just like "use Some::Module 1.02" | |
638 | \& BEGIN { use_ok('Some::Module', 1.02) } | |
639 | .Ve | |
640 | .Sp | |
641 | Don't try to do this: | |
642 | .Sp | |
643 | .Vb 2 | |
644 | \& BEGIN { | |
645 | \& use_ok('Some::Module'); | |
646 | .Ve | |
647 | .Sp | |
648 | .Vb 3 | |
649 | \& ...some code that depends on the use... | |
650 | \& ...happening at compile time... | |
651 | \& } | |
652 | .Ve | |
653 | .Sp | |
654 | because the notion of \*(L"compile\-time\*(R" is relative. Instead, you want: | |
655 | .Sp | |
656 | .Vb 2 | |
657 | \& BEGIN { use_ok('Some::Module') } | |
658 | \& BEGIN { ...some code that depends on the use... } | |
659 | .Ve | |
660 | .IP "\fBrequire_ok\fR" 4 | |
661 | .IX Item "require_ok" | |
662 | .Vb 2 | |
663 | \& require_ok($module); | |
664 | \& require_ok($file); | |
665 | .Ve | |
666 | .Sp | |
667 | Like \fIuse_ok()\fR, except it requires the \f(CW$module\fR or \f(CW$file\fR. | |
668 | .Sh "Complex data structures" | |
669 | .IX Subsection "Complex data structures" | |
670 | Not everything is a simple eq check or regex. There are times you | |
671 | need to see if two data structures are equivalent. For these | |
672 | instances Test::More provides a handful of useful functions. | |
673 | .PP | |
674 | \&\fB\s-1NOTE\s0\fR I'm not quite sure what will happen with filehandles. | |
675 | .IP "\fBis_deeply\fR" 4 | |
676 | .IX Item "is_deeply" | |
677 | .Vb 1 | |
678 | \& is_deeply( $this, $that, $test_name ); | |
679 | .Ve | |
680 | .Sp | |
681 | Similar to \fIis()\fR, except that if \f(CW$this\fR and \f(CW$that\fR are references, it | |
682 | does a deep comparison walking each data structure to see if they are | |
683 | equivalent. If the two structures are different, it will display the | |
684 | place where they start differing. | |
685 | .Sp | |
686 | \&\fIis_deeply()\fR compares the dereferenced values of references, the | |
687 | references themselves (except for their type) are ignored. This means | |
688 | aspects such as blessing and ties are not considered \*(L"different\*(R". | |
689 | .Sp | |
690 | \&\fIis_deeply()\fR current has very limited handling of function reference | |
691 | and globs. It merely checks if they have the same referent. This may | |
692 | improve in the future. | |
693 | .Sp | |
694 | Test::Differences and Test::Deep provide more in-depth functionality | |
695 | along these lines. | |
696 | .Sh "Diagnostics" | |
697 | .IX Subsection "Diagnostics" | |
698 | If you pick the right test function, you'll usually get a good idea of | |
699 | what went wrong when it failed. But sometimes it doesn't work out | |
700 | that way. So here we have ways for you to write your own diagnostic | |
701 | messages which are safer than just \f(CW\*(C`print STDERR\*(C'\fR. | |
702 | .IP "\fBdiag\fR" 4 | |
703 | .IX Item "diag" | |
704 | .Vb 1 | |
705 | \& diag(@diagnostic_message); | |
706 | .Ve | |
707 | .Sp | |
708 | Prints a diagnostic message which is guaranteed not to interfere with | |
709 | test output. Like \f(CW\*(C`print\*(C'\fR \f(CW@diagnostic_message\fR is simply concatenated | |
710 | together. | |
711 | .Sp | |
712 | Handy for this sort of thing: | |
713 | .Sp | |
714 | .Vb 2 | |
715 | \& ok( grep(/foo/, @users), "There's a foo user" ) or | |
716 | \& diag("Since there's no foo, check that /etc/bar is set up right"); | |
717 | .Ve | |
718 | .Sp | |
719 | which would produce: | |
720 | .Sp | |
721 | .Vb 4 | |
722 | \& not ok 42 - There's a foo user | |
723 | \& # Failed test 'There's a foo user' | |
724 | \& # in foo.t at line 52. | |
725 | \& # Since there's no foo, check that /etc/bar is set up right. | |
726 | .Ve | |
727 | .Sp | |
728 | You might remember \f(CW\*(C`ok() or diag()\*(C'\fR with the mnemonic \f(CW\*(C`open() or | |
729 | die()\*(C'\fR. | |
730 | .Sp | |
731 | \&\fB\s-1NOTE\s0\fR The exact formatting of the diagnostic output is still | |
732 | changing, but it is guaranteed that whatever you throw at it it won't | |
733 | interfere with the test. | |
734 | .Sh "Conditional tests" | |
735 | .IX Subsection "Conditional tests" | |
736 | Sometimes running a test under certain conditions will cause the | |
737 | test script to die. A certain function or method isn't implemented | |
738 | (such as \fIfork()\fR on MacOS), some resource isn't available (like a | |
739 | net connection) or a module isn't available. In these cases it's | |
740 | necessary to skip tests, or declare that they are supposed to fail | |
741 | but will work in the future (a todo test). | |
742 | .PP | |
743 | For more details on the mechanics of skip and todo tests see | |
744 | Test::Harness. | |
745 | .PP | |
746 | The way Test::More handles this is with a named block. Basically, a | |
747 | block of tests which can be skipped over or made todo. It's best if I | |
748 | just show you... | |
749 | .IP "\fB\s-1SKIP:\s0 \s-1BLOCK\s0\fR" 4 | |
750 | .IX Item "SKIP: BLOCK" | |
751 | .Vb 2 | |
752 | \& SKIP: { | |
753 | \& skip $why, $how_many if $condition; | |
754 | .Ve | |
755 | .Sp | |
756 | .Vb 2 | |
757 | \& ...normal testing code goes here... | |
758 | \& } | |
759 | .Ve | |
760 | .Sp | |
761 | This declares a block of tests that might be skipped, \f(CW$how_many\fR tests | |
762 | there are, \f(CW$why\fR and under what \f(CW$condition\fR to skip them. An example is | |
763 | the easiest way to illustrate: | |
764 | .Sp | |
765 | .Vb 2 | |
766 | \& SKIP: { | |
767 | \& eval { require HTML::Lint }; | |
768 | .Ve | |
769 | .Sp | |
770 | .Vb 1 | |
771 | \& skip "HTML::Lint not installed", 2 if $@; | |
772 | .Ve | |
773 | .Sp | |
774 | .Vb 2 | |
775 | \& my $lint = new HTML::Lint; | |
776 | \& isa_ok( $lint, "HTML::Lint" ); | |
777 | .Ve | |
778 | .Sp | |
779 | .Vb 3 | |
780 | \& $lint->parse( $html ); | |
781 | \& is( $lint->errors, 0, "No errors found in HTML" ); | |
782 | \& } | |
783 | .Ve | |
784 | .Sp | |
785 | If the user does not have HTML::Lint installed, the whole block of | |
786 | code \fIwon't be run at all\fR. Test::More will output special ok's | |
787 | which Test::Harness interprets as skipped, but passing, tests. | |
788 | .Sp | |
789 | It's important that \f(CW$how_many\fR accurately reflects the number of tests | |
790 | in the \s-1SKIP\s0 block so the # of tests run will match up with your plan. | |
791 | If your plan is \f(CW\*(C`no_plan\*(C'\fR \f(CW$how_many\fR is optional and will default to 1. | |
792 | .Sp | |
793 | It's perfectly safe to nest \s-1SKIP\s0 blocks. Each \s-1SKIP\s0 block must have | |
794 | the label \f(CW\*(C`SKIP\*(C'\fR, or Test::More can't work its magic. | |
795 | .Sp | |
796 | You don't skip tests which are failing because there's a bug in your | |
797 | program, or for which you don't yet have code written. For that you | |
798 | use \s-1TODO\s0. Read on. | |
799 | .IP "\fB\s-1TODO:\s0 \s-1BLOCK\s0\fR" 4 | |
800 | .IX Item "TODO: BLOCK" | |
801 | .Vb 2 | |
802 | \& TODO: { | |
803 | \& local $TODO = $why if $condition; | |
804 | .Ve | |
805 | .Sp | |
806 | .Vb 2 | |
807 | \& ...normal testing code goes here... | |
808 | \& } | |
809 | .Ve | |
810 | .Sp | |
811 | Declares a block of tests you expect to fail and \f(CW$why\fR. Perhaps it's | |
812 | because you haven't fixed a bug or haven't finished a new feature: | |
813 | .Sp | |
814 | .Vb 2 | |
815 | \& TODO: { | |
816 | \& local $TODO = "URI::Geller not finished"; | |
817 | .Ve | |
818 | .Sp | |
819 | .Vb 2 | |
820 | \& my $card = "Eight of clubs"; | |
821 | \& is( URI::Geller->your_card, $card, 'Is THIS your card?' ); | |
822 | .Ve | |
823 | .Sp | |
824 | .Vb 4 | |
825 | \& my $spoon; | |
826 | \& URI::Geller->bend_spoon; | |
827 | \& is( $spoon, 'bent', "Spoon bending, that's original" ); | |
828 | \& } | |
829 | .Ve | |
830 | .Sp | |
831 | With a todo block, the tests inside are expected to fail. Test::More | |
832 | will run the tests normally, but print out special flags indicating | |
833 | they are \*(L"todo\*(R". Test::Harness will interpret failures as being ok. | |
834 | Should anything succeed, it will report it as an unexpected success. | |
835 | You then know the thing you had todo is done and can remove the | |
836 | \&\s-1TODO\s0 flag. | |
837 | .Sp | |
838 | The nice part about todo tests, as opposed to simply commenting out a | |
839 | block of tests, is it's like having a programmatic todo list. You know | |
840 | how much work is left to be done, you're aware of what bugs there are, | |
841 | and you'll know immediately when they're fixed. | |
842 | .Sp | |
843 | Once a todo test starts succeeding, simply move it outside the block. | |
844 | When the block is empty, delete it. | |
845 | .Sp | |
846 | \&\fB\s-1NOTE\s0\fR: \s-1TODO\s0 tests require a Test::Harness upgrade else it will | |
847 | treat it as a normal failure. See \*(L"\s-1CAVEATS\s0 and \s-1NOTES\s0\*(R"). | |
848 | .IP "\fBtodo_skip\fR" 4 | |
849 | .IX Item "todo_skip" | |
850 | .Vb 2 | |
851 | \& TODO: { | |
852 | \& todo_skip $why, $how_many if $condition; | |
853 | .Ve | |
854 | .Sp | |
855 | .Vb 2 | |
856 | \& ...normal testing code... | |
857 | \& } | |
858 | .Ve | |
859 | .Sp | |
860 | With todo tests, it's best to have the tests actually run. That way | |
861 | you'll know when they start passing. Sometimes this isn't possible. | |
862 | Often a failing test will cause the whole program to die or hang, even | |
863 | inside an \f(CW\*(C`eval BLOCK\*(C'\fR with and using \f(CW\*(C`alarm\*(C'\fR. In these extreme | |
864 | cases you have no choice but to skip over the broken tests entirely. | |
865 | .Sp | |
866 | The syntax and behavior is similar to a \f(CW\*(C`SKIP: BLOCK\*(C'\fR except the | |
867 | tests will be marked as failing but todo. Test::Harness will | |
868 | interpret them as passing. | |
869 | .IP "When do I use \s-1SKIP\s0 vs. \s-1TODO\s0?" 4 | |
870 | .IX Item "When do I use SKIP vs. TODO?" | |
871 | \&\fBIf it's something the user might not be able to do\fR, use \s-1SKIP\s0. | |
872 | This includes optional modules that aren't installed, running under | |
873 | an \s-1OS\s0 that doesn't have some feature (like \fIfork()\fR or symlinks), or maybe | |
874 | you need an Internet connection and one isn't available. | |
875 | .Sp | |
876 | \&\fBIf it's something the programmer hasn't done yet\fR, use \s-1TODO\s0. This | |
877 | is for any code you haven't written yet, or bugs you have yet to fix, | |
878 | but want to put tests in your testing script (always a good idea). | |
879 | .Sh "Test control" | |
880 | .IX Subsection "Test control" | |
881 | .IP "\fB\s-1BAIL_OUT\s0\fR" 4 | |
882 | .IX Item "BAIL_OUT" | |
883 | .Vb 1 | |
884 | \& BAIL_OUT($reason); | |
885 | .Ve | |
886 | .Sp | |
887 | Incidates to the harness that things are going so badly all testing | |
888 | should terminate. This includes the running any additional test scripts. | |
889 | .Sp | |
890 | This is typically used when testing cannot continue such as a critical | |
891 | module failing to compile or a necessary external utility not being | |
892 | available such as a database connection failing. | |
893 | .Sp | |
894 | The test will exit with 255. | |
895 | .Sh "Discouraged comparison functions" | |
896 | .IX Subsection "Discouraged comparison functions" | |
897 | The use of the following functions is discouraged as they are not | |
898 | actually testing functions and produce no diagnostics to help figure | |
899 | out what went wrong. They were written before \fIis_deeply()\fR existed | |
900 | because I couldn't figure out how to display a useful diff of two | |
901 | arbitrary data structures. | |
902 | .PP | |
903 | These functions are usually used inside an \fIok()\fR. | |
904 | .PP | |
905 | .Vb 1 | |
906 | \& ok( eq_array(\e@this, \e@that) ); | |
907 | .Ve | |
908 | .PP | |
909 | \&\f(CW\*(C`is_deeply()\*(C'\fR can do that better and with diagnostics. | |
910 | .PP | |
911 | .Vb 1 | |
912 | \& is_deeply( \e@this, \e@that ); | |
913 | .Ve | |
914 | .PP | |
915 | They may be deprecated in future versions. | |
916 | .IP "\fBeq_array\fR" 4 | |
917 | .IX Item "eq_array" | |
918 | .Vb 1 | |
919 | \& my $is_eq = eq_array(\e@this, \e@that); | |
920 | .Ve | |
921 | .Sp | |
922 | Checks if two arrays are equivalent. This is a deep check, so | |
923 | multi-level structures are handled correctly. | |
924 | .IP "\fBeq_hash\fR" 4 | |
925 | .IX Item "eq_hash" | |
926 | .Vb 1 | |
927 | \& my $is_eq = eq_hash(\e%this, \e%that); | |
928 | .Ve | |
929 | .Sp | |
930 | Determines if the two hashes contain the same keys and values. This | |
931 | is a deep check. | |
932 | .IP "\fBeq_set\fR" 4 | |
933 | .IX Item "eq_set" | |
934 | .Vb 1 | |
935 | \& my $is_eq = eq_set(\e@this, \e@that); | |
936 | .Ve | |
937 | .Sp | |
938 | Similar to \fIeq_array()\fR, except the order of the elements is \fBnot\fR | |
939 | important. This is a deep check, but the irrelevancy of order only | |
940 | applies to the top level. | |
941 | .Sp | |
942 | .Vb 1 | |
943 | \& ok( eq_set(\e@this, \e@that) ); | |
944 | .Ve | |
945 | .Sp | |
946 | Is better written: | |
947 | .Sp | |
948 | .Vb 1 | |
949 | \& is_deeply( [sort @this], [sort @that] ); | |
950 | .Ve | |
951 | .Sp | |
952 | \&\fB\s-1NOTE\s0\fR By historical accident, this is not a true set comparison. | |
953 | While the order of elements does not matter, duplicate elements do. | |
954 | .Sp | |
955 | \&\fB\s-1NOTE\s0\fR \fIeq_set()\fR does not know how to deal with references at the top | |
956 | level. The following is an example of a comparison which might not work: | |
957 | .Sp | |
958 | .Vb 1 | |
959 | \& eq_set([\e1, \e2], [\e2, \e1]); | |
960 | .Ve | |
961 | .Sp | |
962 | Test::Deep contains much better set comparison functions. | |
963 | .Sh "Extending and Embedding Test::More" | |
964 | .IX Subsection "Extending and Embedding Test::More" | |
965 | Sometimes the Test::More interface isn't quite enough. Fortunately, | |
966 | Test::More is built on top of Test::Builder which provides a single, | |
967 | unified backend for any test library to use. This means two test | |
968 | libraries which both use Test::Builder \fBcan be used together in the | |
969 | same program\fR. | |
970 | .PP | |
971 | If you simply want to do a little tweaking of how the tests behave, | |
972 | you can access the underlying Test::Builder object like so: | |
973 | .IP "\fBbuilder\fR" 4 | |
974 | .IX Item "builder" | |
975 | .Vb 1 | |
976 | \& my $test_builder = Test::More->builder; | |
977 | .Ve | |
978 | .Sp | |
979 | Returns the Test::Builder object underlying Test::More for you to play | |
980 | with. | |
981 | .SH "EXIT CODES" | |
982 | .IX Header "EXIT CODES" | |
983 | If all your tests passed, Test::Builder will exit with zero (which is | |
984 | normal). If anything failed it will exit with how many failed. If | |
985 | you run less (or more) tests than you planned, the missing (or extras) | |
986 | will be considered failures. If no tests were ever run Test::Builder | |
987 | will throw a warning and exit with 255. If the test died, even after | |
988 | having successfully completed all its tests, it will still be | |
989 | considered a failure and will exit with 255. | |
990 | .PP | |
991 | So the exit codes are... | |
992 | .PP | |
993 | .Vb 3 | |
994 | \& 0 all tests successful | |
995 | \& 255 test died or all passed but wrong # of tests run | |
996 | \& any other number how many failed (including missing or extras) | |
997 | .Ve | |
998 | .PP | |
999 | If you fail more than 254 tests, it will be reported as 254. | |
1000 | .PP | |
1001 | \&\fB\s-1NOTE\s0\fR This behavior may go away in future versions. | |
1002 | .SH "CAVEATS and NOTES" | |
1003 | .IX Header "CAVEATS and NOTES" | |
1004 | .IP "Backwards compatibility" 4 | |
1005 | .IX Item "Backwards compatibility" | |
1006 | Test::More works with Perls as old as 5.004_05. | |
1007 | .IP "Overloaded objects" 4 | |
1008 | .IX Item "Overloaded objects" | |
1009 | String overloaded objects are compared \fBas strings\fR (or in \fIcmp_ok()\fR's | |
1010 | case, strings or numbers as appropriate to the comparison op). This | |
1011 | prevents Test::More from piercing an object's interface allowing | |
1012 | better blackbox testing. So if a function starts returning overloaded | |
1013 | objects instead of bare strings your tests won't notice the | |
1014 | difference. This is good. | |
1015 | .Sp | |
1016 | However, it does mean that functions like \fIis_deeply()\fR cannot be used to | |
1017 | test the internals of string overloaded objects. In this case I would | |
1018 | suggest Test::Deep which contains more flexible testing functions for | |
1019 | complex data structures. | |
1020 | .IP "Threads" 4 | |
1021 | .IX Item "Threads" | |
1022 | Test::More will only be aware of threads if \*(L"use threads\*(R" has been done | |
1023 | \&\fIbefore\fR Test::More is loaded. This is ok: | |
1024 | .Sp | |
1025 | .Vb 2 | |
1026 | \& use threads; | |
1027 | \& use Test::More; | |
1028 | .Ve | |
1029 | .Sp | |
1030 | This may cause problems: | |
1031 | .Sp | |
1032 | .Vb 2 | |
1033 | \& use Test::More | |
1034 | \& use threads; | |
1035 | .Ve | |
1036 | .IP "Test::Harness upgrade" 4 | |
1037 | .IX Item "Test::Harness upgrade" | |
1038 | no_plan and todo depend on new Test::Harness features and fixes. If | |
1039 | you're going to distribute tests that use no_plan or todo your | |
1040 | end-users will have to upgrade Test::Harness to the latest one on | |
1041 | \&\s-1CPAN\s0. If you avoid no_plan and \s-1TODO\s0 tests, the stock Test::Harness | |
1042 | will work fine. | |
1043 | .Sp | |
1044 | Installing Test::More should also upgrade Test::Harness. | |
1045 | .SH "HISTORY" | |
1046 | .IX Header "HISTORY" | |
1047 | This is a case of convergent evolution with Joshua Pritikin's Test | |
1048 | module. I was largely unaware of its existence when I'd first | |
1049 | written my own \fIok()\fR routines. This module exists because I can't | |
1050 | figure out how to easily wedge test names into Test's interface (along | |
1051 | with a few other problems). | |
1052 | .PP | |
1053 | The goal here is to have a testing utility that's simple to learn, | |
1054 | quick to use and difficult to trip yourself up with while still | |
1055 | providing more flexibility than the existing Test.pm. As such, the | |
1056 | names of the most common routines are kept tiny, special cases and | |
1057 | magic side-effects are kept to a minimum. \s-1WYSIWYG\s0. | |
1058 | .SH "SEE ALSO" | |
1059 | .IX Header "SEE ALSO" | |
1060 | Test::Simple if all this confuses you and you just want to write | |
1061 | some tests. You can upgrade to Test::More later (it's forward | |
1062 | compatible). | |
1063 | .PP | |
1064 | Test is the old testing module. Its main benefit is that it has | |
1065 | been distributed with Perl since 5.004_05. | |
1066 | .PP | |
1067 | Test::Harness for details on how your test results are interpreted | |
1068 | by Perl. | |
1069 | .PP | |
1070 | Test::Differences for more ways to test complex data structures. | |
1071 | And it plays well with Test::More. | |
1072 | .PP | |
1073 | Test::Class is like XUnit but more perlish. | |
1074 | .PP | |
1075 | Test::Deep gives you more powerful complex data structure testing. | |
1076 | .PP | |
1077 | Test::Unit is XUnit style testing. | |
1078 | .PP | |
1079 | Test::Inline shows the idea of embedded testing. | |
1080 | .PP | |
1081 | Bundle::Test installs a whole bunch of useful test modules. | |
1082 | .SH "AUTHORS" | |
1083 | .IX Header "AUTHORS" | |
1084 | Michael G Schwern <schwern@pobox.com> with much inspiration | |
1085 | from Joshua Pritikin's Test module and lots of help from Barrie | |
1086 | Slaymaker, Tony Bowden, blackstar.co.uk, chromatic, Fergal Daly and | |
1087 | the perl-qa gang. | |
1088 | .SH "BUGS" | |
1089 | .IX Header "BUGS" | |
1090 | See \fIhttp://rt.cpan.org\fR to report and view bugs. | |
1091 | .SH "COPYRIGHT" | |
1092 | .IX Header "COPYRIGHT" | |
1093 | Copyright 2001, 2002, 2004 by Michael G Schwern <schwern@pobox.com>. | |
1094 | .PP | |
1095 | This program is free software; you can redistribute it and/or | |
1096 | modify it under the same terms as Perl itself. | |
1097 | .PP | |
1098 | See \fIhttp://www.perl.com/perl/misc/Artistic.html\fR |