{
    "mode": "perldoc",
    "parameter": "Test2::Formatter",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Test2%3A%3AFormatter/json",
    "generated": "2026-06-10T16:24:10Z",
    "sections": {
        "NAME": {
            "content": "Test2::Formatter - Namespace for formatters.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is the namespace for formatters. This is an empty package.\n",
            "subsections": []
        },
        "CREATING FORMATTERS": {
            "content": "A formatter is any package or object with a \"write($event, $num)\" method.\n\npackage Test2::Formatter::Foo;\nuse strict;\nuse warnings;\n\nsub write {\nmy $selforclass = shift;\nmy ($event, $assertnum) = @;\n...\n}\n\nsub hidebuffered { 1 }\n\nsub terminate { }\n\nsub finalize { }\n\nsub supportstables { return $BOOL }\n\nsub newroot {\nmy $class = shift;\n...\n$class->new(@);\n}\n\n1;\n\nThe \"write\" method is a method, so it either gets a class or instance. The two arguments are the\n$event object it should record, and the $assertnum which is the number of the current assertion\n(ok), or the last assertion if this event is not itself an assertion. The assertion number may\nbe any integer 0 or greater, and may be undefined in some cases.\n\nThe \"hidebuffered()\" method must return a boolean. This is used to tell buffered subtests\nwhether or not to send it events as they are being buffered. See \"runsubtest(...)\" in\nTest2::API for more information.\n\nThe \"terminate\" and \"finalize\" methods are optional methods called that you can implement if the\nformat you're generating needs to handle these cases, for example if you are generating XML and\nneed close open tags.\n\nThe \"terminate\" method is called when an event's \"terminate\" method returns true, for example\nwhen a Test2::Event::Plan has a 'skipall' plan, or when a Test2::Event::Bail event is sent. The\n\"terminate\" method is passed a single argument, the Test2::Event object which triggered the\nterminate.\n\nThe \"finalize\" method is always the last thing called on the formatter, *except when \"terminate\"\nis called for a Bail event*. It is passed the following arguments:\n\nThe \"supportstables\" method should be true if the formatter supports directly rendering table\ndata from the \"info\" facets. This is a newer feature and many older formatters may not support\nit. When not supported the formatter falls back to rendering \"detail\" instead of the \"table\"\ndata.\n\nThe \"newroot\" method is used when constructing a root formatter. The default is to just\ndelegate to the regular \"new()\" method, most formatters can ignore this.\n\n*   The number of tests that were planned\n\n*   The number of tests actually seen\n\n*   The number of tests which failed\n\n*   A boolean indicating whether or not the test suite passed\n\n*   A boolean indicating whether or not this call is for a subtest\n\nThe \"newroot\" method is called when \"Test2::API::Stack\" Initializes the root hub for the first\ntime. Most formatters will simply have this call \"$class->new\", which is the default behavior.\nSome formatters however may want to take extra action during construction of the root formatter,\nthis is where they can do that.\n",
            "subsections": []
        },
        "SOURCE": {
            "content": "The source code repository for Test2 can be found at http://github.com/Test-More/test-more/.\n",
            "subsections": []
        },
        "MAINTAINERS": {
            "content": "Chad Granum <exodist@cpan.org>\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Chad Granum <exodist@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2020 Chad Granum <exodist@cpan.org>.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\nSee http://dev.perl.org/licenses/\n",
            "subsections": []
        }
    },
    "summary": "Test2::Formatter - Namespace for formatters.",
    "flags": [],
    "examples": [],
    "see_also": []
}