other versions
- wheezy 5.14.2-21+deb7u3
- jessie 5.20.2-3+deb8u6
- testing 5.24.1-3
- unstable 5.24.1-3
- experimental 5.26.0-1
other sections
Test::Builder::Tester(3perl) | Perl Programmers Reference Guide | Test::Builder::Tester(3perl) |
NAME¶
Test::Builder::Tester - test testsuites that have been built with Test::BuilderSYNOPSIS¶
use Test::Builder::Tester tests => 1; use Test::More; test_out("not ok 1 - foo"); test_fail(+1); fail("foo"); test_test("fail works");
DESCRIPTION¶
A module that helps you test testing modules that are built with Test::Builder. 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 "test_out" and "test_err" in advance to declare what the testsuite you are testing will output with Test::Builder to stdout and stderr. You then can run the test(s) from your test suite that call Test::Builder. At this point the output of Test::Builder is safely captured by Test::Builder::Tester rather than being interpreted as real test output. The final stage is to call "test_test" that will simply compare what you predeclared to what Test::Builder actually outputted, and report the results back with a "ok" or "not ok" (with debugging) to the normal output.Functions¶
These are the six methods that are exported as default.- test_out
- test_err
- 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
test_out("ok 1","ok 2");
test_out("ok 1\nok 2");
test_out("ok 1"); test_out("ok 2");
- test_fail
- 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 so
test_err("# Failed test ($0 at line ".line_num(+1).")");
test_fail(+1);
test_out("not ok 1 - foo"); test_fail(+1); fail("foo"); test_test("fail works");
- test_diag
- As most of the remaining expected output to the error
stream will be created by Test::Builder's "diag" function,
Test::Builder::Tester provides a convenience function
"test_diag" that you can use instead of "test_err".
test_err("# Couldn't open file");
test_diag("Couldn't open file");
Test::Builder->new->diag("foo\n","bar\n");
test_diag("foo","bar")
- test_test
- Actually performs the output check testing the tests,
comparing the data (with "eq") that we have captured from
Test::Builder against that that was declared with
"test_out" and "test_err".
- title (synonym 'name', 'label')
- The name of the test that will be displayed after the "ok" or "not ok".
- 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 "test_out".
- 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 "test_err".
- 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.
- color
- 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.
perl -Mlib=Text::Builder::Tester::Color test.t
BUGS¶
Calls "<Test::Builder-"no_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. The color function doesn't work unless Term::ANSIColor is compatible with your terminal. Bugs (and requests for new features) can be reported to the author though the CPAN RT system: http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Builder-Tester <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Builder-Tester>AUTHOR¶
Copyright Mark Fowler <mark@twoshortplanks.com> 2002, 2004. Some code taken from Test::More and Test::Catch, written by by Michael G Schwern <schwern@pobox.com>. Hence, those parts Copyright Micheal G Schwern 2001. Used and distributed with permission. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.NOTES¶
Thanks to Richard Clamp <richardc@unixbeard.net> for letting me use his testing system to try this module out on.SEE ALSO¶
Test::Builder, Test::Builder::Tester::Color, Test::More.2011-09-19 | perl v5.14.2 |