.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Test::Builder::Tester 3perl"
.TH Test::Builder::Tester 3perl "2014-01-06" "perl v5.18.2" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Test::Builder::Tester \- test testsuites that have been built with
Test::Builder
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\&    use Test::Builder::Tester tests => 1;
\&    use Test::More;
\&
\&    test_out("not ok 1 \- foo");
\&    test_fail(+1);
\&    fail("foo");
\&    test_test("fail works");
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
A module that helps you test testing modules that are built with
\&\fBTest::Builder\fR.
.PP
The testing system is designed to be used by performing a three step
process for each test you wish to test.  This process starts with using
\&\f(CW\*(C`test_out\*(C'\fR and \f(CW\*(C`test_err\*(C'\fR in advance to declare what the testsuite you
are testing will output with \fBTest::Builder\fR to stdout and stderr.
.PP
You then can run the test(s) from your test suite that call
\&\fBTest::Builder\fR.  At this point the output of \fBTest::Builder\fR is
safely captured by \fBTest::Builder::Tester\fR rather than being
interpreted as real test output.
.PP
The final stage is to call \f(CW\*(C`test_test\*(C'\fR that will simply compare what you
predeclared to what \fBTest::Builder\fR actually outputted, and report the
results back with a \*(L"ok\*(R" or \*(L"not ok\*(R" (with debugging) to the normal
output.
.SS "Functions"
.IX Subsection "Functions"
These are the six methods that are exported as default.
.IP "test_out" 4
.IX Item "test_out"
.PD 0
.IP "test_err" 4
.IX Item "test_err"
.PD
Procedures for predeclaring the output that your test suite is
expected to produce until \f(CW\*(C`test_test\*(C'\fR is called.  These procedures
automatically assume that each line terminates with \*(L"\en\*(R".  So
.Sp
.Vb 1
\&   test_out("ok 1","ok 2");
.Ve
.Sp
is the same as
.Sp
.Vb 1
\&   test_out("ok 1\enok 2");
.Ve
.Sp
which is even the same as
.Sp
.Vb 2
\&   test_out("ok 1");
\&   test_out("ok 2");
.Ve
.Sp
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
been called, all further output from \fBTest::Builder\fR will be
captured by \fBTest::Builder::Tester\fR.  This means that you will not
be able perform further tests to the normal output in the normal way
until you call \f(CW\*(C`test_test\*(C'\fR (well, unless you manually meddle with the
output filehandles)
.IP "test_fail" 4
.IX Item "test_fail"
Because the standard failure message that \fBTest::Builder\fR produces
whenever a test fails will be a common occurrence in your test error
output, and because it has changed between Test::Builder versions, rather
than forcing you to call \f(CW\*(C`test_err\*(C'\fR with the string all the time like
so
.Sp
.Vb 1
\&    test_err("# Failed test ($0 at line ".line_num(+1).")");
.Ve
.Sp
\&\f(CW\*(C`test_fail\*(C'\fR exists as a convenience function that can be called
instead.  It takes one argument, the offset from the current line that
the line that causes the fail is on.
.Sp
.Vb 1
\&    test_fail(+1);
.Ve
.Sp
This means that the example in the synopsis could be rewritten
more simply as:
.Sp
.Vb 4
\&   test_out("not ok 1 \- foo");
\&   test_fail(+1);
\&   fail("foo");
\&   test_test("fail works");
.Ve
.IP "test_diag" 4
.IX Item "test_diag"
As most of the remaining expected output to the error stream will be
created by Test::Builder's \f(CW\*(C`diag\*(C'\fR function, \fBTest::Builder::Tester\fR
provides a convenience function \f(CW\*(C`test_diag\*(C'\fR that you can use instead of
\&\f(CW\*(C`test_err\*(C'\fR.
.Sp
The \f(CW\*(C`test_diag\*(C'\fR function prepends comment hashes and spacing to the
start and newlines to the end of the expected output passed to it and
adds it to the list of expected error output.  So, instead of writing
.Sp
.Vb 1
\&   test_err("# Couldn\*(Aqt open file");
.Ve
.Sp
you can write
.Sp
.Vb 1
\&   test_diag("Couldn\*(Aqt open file");
.Ve
.Sp
Remember that \fBTest::Builder\fR's diag function will not add newlines to
the end of output and test_diag will. So to check
.Sp
.Vb 1
\&   Test::Builder\->new\->diag("foo\en","bar\en");
.Ve
.Sp
You would do
.Sp
.Vb 1
\&  test_diag("foo","bar")
.Ve
.Sp
without the newlines.
.IP "test_test" 4
.IX Item "test_test"
Actually performs the output check testing the tests, comparing the
data (with \f(CW\*(C`eq\*(C'\fR) that we have captured from \fBTest::Builder\fR against
that that was declared with \f(CW\*(C`test_out\*(C'\fR and \f(CW\*(C`test_err\*(C'\fR.
.Sp
This takes name/value pairs that effect how the test is run.
.RS 4
.IP "title (synonym 'name', 'label')" 4
.IX Item "title (synonym 'name', 'label')"
The name of the test that will be displayed after the \f(CW\*(C`ok\*(C'\fR or \f(CW\*(C`not
ok\*(C'\fR.
.IP "skip_out" 4
.IX Item "skip_out"
Setting this to a true value will cause the test to ignore if the
output sent by the test to the output stream does not match that
declared with \f(CW\*(C`test_out\*(C'\fR.
.IP "skip_err" 4
.IX Item "skip_err"
Setting this to a true value will cause the test to ignore if the
output sent by the test to the error stream does not match that
declared with \f(CW\*(C`test_err\*(C'\fR.
.RE
.RS 4
.Sp
As a convenience, if only one argument is passed then this argument
is assumed to be the name of the test (as in the above examples.)
.Sp
Once \f(CW\*(C`test_test\*(C'\fR has been run test output will be redirected back to
the original filehandles that \fBTest::Builder\fR was connected to
(probably \s-1STDOUT\s0 and \s-1STDERR,\s0) meaning any further tests you run
will function normally and cause success/errors for \fBTest::Harness\fR.
.RE
.IP "line_num" 4
.IX Item "line_num"
A utility function that returns the line number that the function was
called on.  You can pass it an offset which will be added to the
result.  This is very useful for working out the correct text of
diagnostic functions that contain line numbers.
.Sp
Essentially this is the same as the \f(CW\*(C`_\|_LINE_\|_\*(C'\fR macro, but the
\&\f(CW\*(C`line_num(+3)\*(C'\fR idiom is arguably nicer.
.PP
In addition to the six exported functions there exists one
function that can only be accessed with a fully qualified function
call.
.IP "color" 4
.IX Item "color"
When \f(CW\*(C`test_test\*(C'\fR is called and the output that your tests generate
does not match that which you declared, \f(CW\*(C`test_test\*(C'\fR will print out
debug information showing the two conflicting versions.  As this
output itself is debug information it can be confusing which part of
the output is from \f(CW\*(C`test_test\*(C'\fR and which was the original output from
your original tests.  Also, it may be hard to spot things like
extraneous whitespace at the end of lines that may cause your test to
fail even though the output looks similar.
.Sp
To assist you \f(CW\*(C`test_test\*(C'\fR can colour the background of the debug
information to disambiguate the different types of output. The debug
output will have its background coloured green and red.  The green
part represents the text which is the same between the executed and
actual output, the red shows which part differs.
.Sp
The \f(CW\*(C`color\*(C'\fR function determines if colouring should occur or not.
Passing it a true or false value will enable or disable colouring
respectively, and the function called with no argument will return the
current setting.
.Sp
To enable colouring from the command line, you can use the
\&\fBText::Builder::Tester::Color\fR module like so:
.Sp
.Vb 1
\&   perl \-Mlib=Text::Builder::Tester::Color test.t
.Ve
.Sp
Or by including the \fBTest::Builder::Tester::Color\fR module directly in
the \s-1PERL5LIB.\s0
.SH "BUGS"
.IX Header "BUGS"
Calls \f(CW\*(C`<Test::Builder\-\*(C'\fRno_ending>> turning off the ending tests.
This is needed as otherwise it will trip out because we've run more
tests than we strictly should have and it'll register any failures we
had that we were testing for as real failures.
.PP
The color function doesn't work unless \fBTerm::ANSIColor\fR is
compatible with your terminal.
.PP
Bugs (and requests for new features) can be reported to the author
though the \s-1CPAN RT\s0 system:
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test\-Builder\-Tester>
.SH "AUTHOR"
.IX Header "AUTHOR"
Copyright Mark Fowler <mark@twoshortplanks.com> 2002, 2004.
.PP
Some code taken from \fBTest::More\fR and \fBTest::Catch\fR, written by by
Michael G Schwern <schwern@pobox.com>.  Hence, those parts
Copyright Micheal G Schwern 2001.  Used and distributed with
permission.
.PP
This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
.SH "NOTES"
.IX Header "NOTES"
Thanks to Richard Clamp <richardc@unixbeard.net> for letting
me use his testing system to try this module out on.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Test::Builder, Test::Builder::Tester::Color, Test::More.
