{
    "mode": "perldoc",
    "parameter": "Test::Builder::Tester",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Test%3A%3ABuilder%3A%3ATester/json",
    "generated": "2026-06-15T14:57:22Z",
    "synopsis": "use Test::Builder::Tester tests => 1;\nuse Test::More;\ntestout(\"not ok 1 - foo\");\ntestfail(+1);\nfail(\"foo\");\ntesttest(\"fail works\");",
    "sections": {
        "NAME": {
            "content": "Test::Builder::Tester - test testsuites that have been built with Test::Builder\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Test::Builder::Tester tests => 1;\nuse Test::More;\n\ntestout(\"not ok 1 - foo\");\ntestfail(+1);\nfail(\"foo\");\ntesttest(\"fail works\");\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "A module that helps you test testing modules that are built with Test::Builder.\n\nThe testing system is designed to be used by performing a three step process for each test you\nwish to test. This process starts with using \"testout\" and \"testerr\" in advance to declare\nwhat the testsuite you are testing will output with Test::Builder to stdout and stderr.\n\nYou then can run the test(s) from your test suite that call Test::Builder. At this point the\noutput of Test::Builder is safely captured by Test::Builder::Tester rather than being\ninterpreted as real test output.\n\nThe final stage is to call \"testtest\" that will simply compare what you predeclared to what\nTest::Builder actually outputted, and report the results back with a \"ok\" or \"not ok\" (with\ndebugging) to the normal output.\n",
            "subsections": [
                {
                    "name": "Functions",
                    "content": "These are the six methods that are exported as default.\n\ntestout\ntesterr\nProcedures for predeclaring the output that your test suite is expected to produce until\n\"testtest\" is called. These procedures automatically assume that each line terminates with\n\"\\n\". So\n\ntestout(\"ok 1\",\"ok 2\");\n\nis the same as\n\ntestout(\"ok 1\\nok 2\");\n\nwhich is even the same as\n\ntestout(\"ok 1\");\ntestout(\"ok 2\");\n\nOnce \"testout\" or \"testerr\" (or \"testfail\" or \"testdiag\") have been called, all further\noutput from Test::Builder will be captured by Test::Builder::Tester. This means that you\nwill not be able perform further tests to the normal output in the normal way until you call\n\"testtest\" (well, unless you manually meddle with the output filehandles)\n\ntestfail\nBecause the standard failure message that Test::Builder produces whenever a test fails will\nbe a common occurrence in your test error output, and because it has changed between\nTest::Builder versions, rather than forcing you to call \"testerr\" with the string all the\ntime like so\n\ntesterr(\"# Failed test ($0 at line \".linenum(+1).\")\");\n\n\"testfail\" exists as a convenience function that can be called instead. It takes one\nargument, the offset from the current line that the line that causes the fail is on.\n\ntestfail(+1);\n\nThis means that the example in the synopsis could be rewritten more simply as:\n\ntestout(\"not ok 1 - foo\");\ntestfail(+1);\nfail(\"foo\");\ntesttest(\"fail works\");\n\ntestdiag\nAs most of the remaining expected output to the error stream will be created by\nTest::Builder's \"diag\" function, Test::Builder::Tester provides a convenience function\n\"testdiag\" that you can use instead of \"testerr\".\n\nThe \"testdiag\" function prepends comment hashes and spacing to the start and newlines to\nthe end of the expected output passed to it and adds it to the list of expected error\noutput. So, instead of writing\n\ntesterr(\"# Couldn't open file\");\n\nyou can write\n\ntestdiag(\"Couldn't open file\");\n\nRemember that Test::Builder's diag function will not add newlines to the end of output and\ntestdiag will. So to check\n\nTest::Builder->new->diag(\"foo\\n\",\"bar\\n\");\n\nYou would do\n\ntestdiag(\"foo\",\"bar\")\n\nwithout the newlines.\n\ntesttest\nActually performs the output check testing the tests, comparing the data (with \"eq\") that we\nhave captured from Test::Builder against what was declared with \"testout\" and \"testerr\".\n\nThis takes name/value pairs that effect how the test is run.\n\ntitle (synonym 'name', 'label')\nThe name of the test that will be displayed after the \"ok\" or \"not ok\".\n\nskipout\nSetting this to a true value will cause the test to ignore if the output sent by the\ntest to the output stream does not match that declared with \"testout\".\n\nskiperr\nSetting this to a true value will cause the test to ignore if the output sent by the\ntest to the error stream does not match that declared with \"testerr\".\n\nAs a convenience, if only one argument is passed then this argument is assumed to be the\nname of the test (as in the above examples.)\n\nOnce \"testtest\" has been run test output will be redirected back to the original\nfilehandles that Test::Builder was connected to (probably STDOUT and STDERR,) meaning any\nfurther tests you run will function normally and cause success/errors for Test::Harness.\n\nlinenum\nA utility function that returns the line number that the function was called on. You can\npass it an offset which will be added to the result. This is very useful for working out the\ncorrect text of diagnostic functions that contain line numbers.\n\nEssentially this is the same as the \"LINE\" macro, but the \"linenum(+3)\" idiom is\narguably nicer.\n\nIn addition to the six exported functions there exists one function that can only be accessed\nwith a fully qualified function call.\n\ncolor\nWhen \"testtest\" is called and the output that your tests generate does not match that which\nyou declared, \"testtest\" will print out debug information showing the two conflicting\nversions. As this output itself is debug information it can be confusing which part of the\noutput is from \"testtest\" and which was the original output from your original tests. Also,\nit may be hard to spot things like extraneous whitespace at the end of lines that may cause\nyour test to fail even though the output looks similar.\n\nTo assist you \"testtest\" can colour the background of the debug information to disambiguate\nthe different types of output. The debug output will have its background coloured green and\nred. The green part represents the text which is the same between the executed and actual\noutput, the red shows which part differs.\n\nThe \"color\" function determines if colouring should occur or not. Passing it a true or false\nvalue will enable or disable colouring respectively, and the function called with no\nargument will return the current setting.\n\nTo enable colouring from the command line, you can use the Text::Builder::Tester::Color\nmodule like so:\n\nperl -Mlib=Text::Builder::Tester::Color test.t\n\nOr by including the Test::Builder::Tester::Color module directly in the PERL5LIB.\n"
                }
            ]
        },
        "BUGS": {
            "content": "Test::Builder::Tester does not handle plans well. It has never done anything special with plans.\nThis means that plans from outside Test::Builder::Tester will effect Test::Builder::Tester,\nworse plans when using Test::Builder::Tester will effect overall testing. At this point there\nare no plans to fix this bug as people have come to depend on it, and Test::Builder::Tester is\nnow discouraged in favor of \"Test2::API::intercept()\". See\n<https://github.com/Test-More/test-more/issues/667>\n\nCalls \"Test::Builder->noending\" turning off the ending tests. This is needed as otherwise it\nwill trip out because we've run more tests than we strictly should have and it'll register any\nfailures we had that we were testing for as real failures.\n\nThe color function doesn't work unless Term::ANSIColor is compatible with your terminal.\nAdditionally, Win32::Console::ANSI must be installed on windows platforms for color output.\n\nBugs (and requests for new features) can be reported to the author though GitHub:\n<https://github.com/Test-More/test-more/issues>\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright Mark Fowler <mark@twoshortplanks.com> 2002, 2004.\n\nSome code taken from Test::More and Test::Catch, written by Michael G Schwern\n<schwern@pobox.com>. Hence, those parts Copyright Micheal G Schwern 2001. Used and distributed\nwith permission.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "MAINTAINERS": {
            "content": "Chad Granum <exodist@cpan.org>\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Thanks to Richard Clamp <richardc@unixbeard.net> for letting me use his testing system to try\nthis module out on.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Test::Builder, Test::Builder::Tester::Color, Test::More.\n",
            "subsections": []
        }
    },
    "summary": "Test::Builder::Tester - test testsuites that have been built with Test::Builder",
    "flags": [],
    "examples": [],
    "see_also": []
}