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::Builder::Tester 3" | |
132 | .TH Test::Builder::Tester 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | Test::Builder::Tester \- test testsuites that have been built with | |
135 | Test::Builder | |
136 | .SH "SYNOPSIS" | |
137 | .IX Header "SYNOPSIS" | |
138 | .Vb 2 | |
139 | \& use Test::Builder::Tester tests => 1; | |
140 | \& use Test::More; | |
141 | .Ve | |
142 | .PP | |
143 | .Vb 4 | |
144 | \& test_out("not ok 1 - foo"); | |
145 | \& test_fail(+1); | |
146 | \& fail("foo"); | |
147 | \& test_test("fail works"); | |
148 | .Ve | |
149 | .SH "DESCRIPTION" | |
150 | .IX Header "DESCRIPTION" | |
151 | A module that helps you test testing modules that are built with | |
152 | \&\fBTest::Builder\fR. | |
153 | .PP | |
154 | The testing system is designed to be used by performing a three step | |
155 | process for each test you wish to test. This process starts with using | |
156 | \&\f(CW\*(C`test_out\*(C'\fR and \f(CW\*(C`test_err\*(C'\fR in advance to declare what the testsuite you | |
157 | are testing will output with \fBTest::Builder\fR to stdout and stderr. | |
158 | .PP | |
159 | You then can run the test(s) from your test suite that call | |
160 | \&\fBTest::Builder\fR. At this point the output of \fBTest::Builder\fR is | |
161 | safely captured by \fBTest::Builder::Tester\fR rather than being | |
162 | interpreted as real test output. | |
163 | .PP | |
164 | The final stage is to call \f(CW\*(C`test_test\*(C'\fR that will simply compare what you | |
165 | predeclared to what \fBTest::Builder\fR actually outputted, and report the | |
166 | results back with a \*(L"ok\*(R" or \*(L"not ok\*(R" (with debugging) to the normal | |
167 | output. | |
168 | .Sh "Methods" | |
169 | .IX Subsection "Methods" | |
170 | These are the six methods that are exported as default. | |
171 | .IP "test_out" 4 | |
172 | .IX Item "test_out" | |
173 | .PD 0 | |
174 | .IP "test_err" 4 | |
175 | .IX Item "test_err" | |
176 | .PD | |
177 | Procedures for predeclaring the output that your test suite is | |
178 | expected to produce until \f(CW\*(C`test_test\*(C'\fR is called. These procedures | |
179 | automatically assume that each line terminates with \*(L"\en\*(R". So | |
180 | .Sp | |
181 | .Vb 1 | |
182 | \& test_out("ok 1","ok 2"); | |
183 | .Ve | |
184 | .Sp | |
185 | is the same as | |
186 | .Sp | |
187 | .Vb 1 | |
188 | \& test_out("ok 1\enok 2"); | |
189 | .Ve | |
190 | .Sp | |
191 | which is even the same as | |
192 | .Sp | |
193 | .Vb 2 | |
194 | \& test_out("ok 1"); | |
195 | \& test_out("ok 2"); | |
196 | .Ve | |
197 | .Sp | |
198 | Once \f(CW\*(C`test_out\*(C'\fR or \f(CW\*(C`test_err\*(C'\fR (or \f(CW\*(C`test_fail\*(C'\fR or \f(CW\*(C`test_diag\*(C'\fR) have | |
199 | been called once all further output from \fBTest::Builder\fR will be | |
200 | captured by \fBTest::Builder::Tester\fR. This means that your will not | |
201 | be able perform further tests to the normal output in the normal way | |
202 | until you call \f(CW\*(C`test_test\*(C'\fR (well, unless you manually meddle with the | |
203 | output filehandles) | |
204 | .IP "test_fail" 4 | |
205 | .IX Item "test_fail" | |
206 | Because the standard failure message that \fBTest::Builder\fR produces | |
207 | whenever a test fails will be a common occurrence in your test error | |
208 | output, and because has changed between Test::Builder versions, rather | |
209 | than forcing you to call \f(CW\*(C`test_err\*(C'\fR with the string all the time like | |
210 | so | |
211 | .Sp | |
212 | .Vb 1 | |
213 | \& test_err("# Failed test ($0 at line ".line_num(+1).")"); | |
214 | .Ve | |
215 | .Sp | |
216 | \&\f(CW\*(C`test_fail\*(C'\fR exists as a convenience method that can be called | |
217 | instead. It takes one argument, the offset from the current line that | |
218 | the line that causes the fail is on. | |
219 | .Sp | |
220 | .Vb 1 | |
221 | \& test_fail(+1); | |
222 | .Ve | |
223 | .Sp | |
224 | This means that the example in the synopsis could be rewritten | |
225 | more simply as: | |
226 | .Sp | |
227 | .Vb 4 | |
228 | \& test_out("not ok 1 - foo"); | |
229 | \& test_fail(+1); | |
230 | \& fail("foo"); | |
231 | \& test_test("fail works"); | |
232 | .Ve | |
233 | .IP "test_diag" 4 | |
234 | .IX Item "test_diag" | |
235 | As most of the remaining expected output to the error stream will be | |
236 | created by Test::Builder's \f(CW\*(C`diag\*(C'\fR function, \fBTest::Builder::Tester\fR | |
237 | provides a convience function \f(CW\*(C`test_diag\*(C'\fR that you can use instead of | |
238 | \&\f(CW\*(C`test_err\*(C'\fR. | |
239 | .Sp | |
240 | The \f(CW\*(C`test_diag\*(C'\fR function prepends comment hashes and spacing to the | |
241 | start and newlines to the end of the expected output passed to it and | |
242 | adds it to the list of expected error output. So, instead of writing | |
243 | .Sp | |
244 | .Vb 1 | |
245 | \& test_err("# Couldn't open file"); | |
246 | .Ve | |
247 | .Sp | |
248 | you can write | |
249 | .Sp | |
250 | .Vb 1 | |
251 | \& test_diag("Couldn't open file"); | |
252 | .Ve | |
253 | .Sp | |
254 | Remember that \fBTest::Builder\fR's diag function will not add newlines to | |
255 | the end of output and test_diag will. So to check | |
256 | .Sp | |
257 | .Vb 1 | |
258 | \& Test::Builder->new->diag("foo\en","bar\en"); | |
259 | .Ve | |
260 | .Sp | |
261 | You would do | |
262 | .Sp | |
263 | .Vb 1 | |
264 | \& test_diag("foo","bar") | |
265 | .Ve | |
266 | .Sp | |
267 | without the newlines. | |
268 | .IP "test_test" 4 | |
269 | .IX Item "test_test" | |
270 | Actually performs the output check testing the tests, comparing the | |
271 | data (with \f(CW\*(C`eq\*(C'\fR) that we have captured from \fBTest::Builder\fR against | |
272 | that that was declared with \f(CW\*(C`test_out\*(C'\fR and \f(CW\*(C`test_err\*(C'\fR. | |
273 | .Sp | |
274 | This takes name/value pairs that effect how the test is run. | |
275 | .RS 4 | |
276 | .IP "title (synonym 'name', 'label')" 4 | |
277 | .IX Item "title (synonym 'name', 'label')" | |
278 | The name of the test that will be displayed after the \f(CW\*(C`ok\*(C'\fR or \f(CW\*(C`not | |
279 | ok\*(C'\fR. | |
280 | .IP "skip_out" 4 | |
281 | .IX Item "skip_out" | |
282 | Setting this to a true value will cause the test to ignore if the | |
283 | output sent by the test to the output stream does not match that | |
284 | declared with \f(CW\*(C`test_out\*(C'\fR. | |
285 | .IP "skip_err" 4 | |
286 | .IX Item "skip_err" | |
287 | Setting this to a true value will cause the test to ignore if the | |
288 | output sent by the test to the error stream does not match that | |
289 | declared with \f(CW\*(C`test_err\*(C'\fR. | |
290 | .RE | |
291 | .RS 4 | |
292 | .Sp | |
293 | As a convience, if only one argument is passed then this argument | |
294 | is assumed to be the name of the test (as in the above examples.) | |
295 | .Sp | |
296 | Once \f(CW\*(C`test_test\*(C'\fR has been run test output will be redirected back to | |
297 | the original filehandles that \fBTest::Builder\fR was connected to | |
298 | (probably \s-1STDOUT\s0 and \s-1STDERR\s0,) meaning any further tests you run | |
299 | will function normally and cause success/errors for \fBTest::Harness\fR. | |
300 | .RE | |
301 | .IP "line_num" 4 | |
302 | .IX Item "line_num" | |
303 | A utility function that returns the line number that the function was | |
304 | called on. You can pass it an offset which will be added to the | |
305 | result. This is very useful for working out the correct text of | |
306 | diagnostic methods that contain line numbers. | |
307 | .Sp | |
308 | Essentially this is the same as the \f(CW\*(C`_\|_LINE_\|_\*(C'\fR macro, but the | |
309 | \&\f(CW\*(C`line_num(+3)\*(C'\fR idiom is arguably nicer. | |
310 | .PP | |
311 | In addition to the six exported functions there there exists one | |
312 | function that can only be accessed with a fully qualified function | |
313 | call. | |
314 | .IP "color" 4 | |
315 | .IX Item "color" | |
316 | When \f(CW\*(C`test_test\*(C'\fR is called and the output that your tests generate | |
317 | does not match that which you declared, \f(CW\*(C`test_test\*(C'\fR will print out | |
318 | debug information showing the two conflicting versions. As this | |
319 | output itself is debug information it can be confusing which part of | |
320 | the output is from \f(CW\*(C`test_test\*(C'\fR and which was the original output from | |
321 | your original tests. Also, it may be hard to spot things like | |
322 | extraneous whitespace at the end of lines that may cause your test to | |
323 | fail even though the output looks similar. | |
324 | .Sp | |
325 | To assist you, if you have the \fBTerm::ANSIColor\fR module installed | |
326 | (which you should do by default from perl 5.005 onwards), \f(CW\*(C`test_test\*(C'\fR | |
327 | can colour the background of the debug information to disambiguate the | |
328 | different types of output. The debug output will have it's background | |
329 | coloured green and red. The green part represents the text which is | |
330 | the same between the executed and actual output, the red shows which | |
331 | part differs. | |
332 | .Sp | |
333 | The \f(CW\*(C`color\*(C'\fR function determines if colouring should occur or not. | |
334 | Passing it a true or false value will enable or disable colouring | |
335 | respectively, and the function called with no argument will return the | |
336 | current setting. | |
337 | .Sp | |
338 | To enable colouring from the command line, you can use the | |
339 | \&\fBText::Builder::Tester::Color\fR module like so: | |
340 | .Sp | |
341 | .Vb 1 | |
342 | \& perl -Mlib=Text::Builder::Tester::Color test.t | |
343 | .Ve | |
344 | .Sp | |
345 | Or by including the \fBTest::Builder::Tester::Color\fR module directly in | |
346 | the \s-1PERL5LIB\s0. | |
347 | .SH "BUGS" | |
348 | .IX Header "BUGS" | |
349 | Calls \fBTest::Builder\fR's \f(CW\*(C`no_ending\*(C'\fR method turning off the ending | |
350 | tests. This is needed as otherwise it will trip out because we've run | |
351 | more tests than we strictly should have and it'll register any | |
352 | failures we had that we were testing for as real failures. | |
353 | .PP | |
354 | The color function doesn't work unless \fBTerm::ANSIColor\fR is installed | |
355 | and is compatible with your terminal. | |
356 | .PP | |
357 | Bugs (and requests for new features) can be reported to the author | |
358 | though the \s-1CPAN\s0 \s-1RT\s0 system: | |
359 | <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test\-Builder\-Tester> | |
360 | .SH "AUTHOR" | |
361 | .IX Header "AUTHOR" | |
362 | Copyright Mark Fowler <mark@twoshortplanks.com> 2002, 2004. | |
363 | .PP | |
364 | Some code taken from \fBTest::More\fR and \fBTest::Catch\fR, written by by | |
365 | Michael G Schwern <schwern@pobox.com>. Hence, those parts | |
366 | Copyright Micheal G Schwern 2001. Used and distributed with | |
367 | permission. | |
368 | .PP | |
369 | This program is free software; you can redistribute it | |
370 | and/or modify it under the same terms as Perl itself. | |
371 | .SH "NOTES" | |
372 | .IX Header "NOTES" | |
373 | This code has been tested explicitly on the following versions | |
374 | of perl: 5.7.3, 5.6.1, 5.6.0, 5.005_03, 5.004_05 and 5.004. | |
375 | .PP | |
376 | Thanks to Richard Clamp <richardc@unixbeard.net> for letting | |
377 | me use his testing system to try this module out on. | |
378 | .SH "SEE ALSO" | |
379 | .IX Header "SEE ALSO" | |
380 | Test::Builder, Test::Builder::Tester::Color, Test::More. |