Procedures for predeclaring the output that your test suite is
expected to produce until test_test is called. These procedures
automatically assume that each line terminates with \n. So
is the same as
which is even the same as
Once test_out or test_err (or test_fail or test_diag) have been called, all further output from Test::Builder will be captured by Test::Builder::Tester. This means that you will not be able perform further tests to the normal output in the normal way until you call test_test (well, unless you manually meddle with the output filehandles)
Because the standard failure message that Test::Builder 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 test_err with the string all the time like
test_fail 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.
This means that the example in the synopsis could be rewritten more simply as:
As most of the remaining expected output to the error stream will be
created by Test::Builders diag function, Test::Builder::Tester
provides a convenience function test_diag that you can use instead of
The test_diag 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
you can write
Remember that Test::Builders diag function will not add newlines to the end of output and test_diag will. So to check
You would do
without the newlines.
Actually performs the output check testing the tests, comparing the
data (with eq) that we have captured from Test::Builder against
what was declared with test_out and test_err.
This takes name/value pairs that effect how the test is run.
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.)
Once test_test has been run test output will be redirected back to the original filehandles that Test::Builder was connected to (probably STDOUT and STDERR,) meaning any further tests you run will function normally and cause success/errors for Test::Harness.
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.
Essentially this is the same as the __LINE__ macro, but the line_num(+3) idiom is arguably nicer.
When test_test is called and the output that your tests generate
does not match that which you declared, test_test 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 test_test 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.
To assist you test_test 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.
The color 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.
To enable colouring from the command line, you can use the Text::Builder::Tester::Color module like so:
Or by including the Test::Builder::Tester::Color module directly in the PERL5LIB.
Calls Test::Builder->no_ending turning off the ending tests. This is needed as otherwise it will trip out because weve run more tests than we strictly should have and itll register any failures we had that we were testing for as real failures.
The color function doesnt work unless Term::ANSIColor is compatible with your terminal.
Copyright Mark Fowler <email@example.com> 2002, 2004.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chad Granum <firstname.lastname@example.org>
Thanks to Richard Clamp <email@example.com> for letting me use his testing system to try this module out on.
|perl v5.20.3||TEST::BUILDER::TESTER (3)||2014-12-28|