{
    "mode": "perldoc",
    "parameter": "Test::Builder::Module",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Test%3A%3ABuilder%3A%3AModule/json",
    "generated": "2026-06-13T00:08:38Z",
    "synopsis": "# Emulates Test::Simple\npackage Your::Module;\nmy $CLASS = PACKAGE;\nuse parent 'Test::Builder::Module';\n@EXPORT = qw(ok);\nsub ok ($;$) {\nmy $tb = $CLASS->builder;\nreturn $tb->ok(@);\n}\n1;",
    "sections": {
        "NAME": {
            "content": "Test::Builder::Module - Base class for test modules\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "# Emulates Test::Simple\npackage Your::Module;\n\nmy $CLASS = PACKAGE;\n\nuse parent 'Test::Builder::Module';\n@EXPORT = qw(ok);\n\nsub ok ($;$) {\nmy $tb = $CLASS->builder;\nreturn $tb->ok(@);\n}\n\n1;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This is a superclass for Test::Builder-based modules. It provides a handful of common\nfunctionality and a method of getting at the underlying Test::Builder object.\n",
            "subsections": [
                {
                    "name": "Importing",
                    "content": "Test::Builder::Module is a subclass of Exporter which means your module is also a subclass of\nExporter. @EXPORT, @EXPORTOK, etc... all act normally.\n\nA few methods are provided to do the \"use Your::Module tests => 23\" part for you.\n\nimport\nTest::Builder::Module provides an \"import()\" method which acts in the same basic way as\nTest::More's, setting the plan and controlling exporting of functions and variables. This allows\nyour module to set the plan independent of Test::More.\n\nAll arguments passed to \"import()\" are passed onto \"Your::Module->builder->plan()\" with the\nexception of \"import =>[qw(things to import)]\".\n\nuse Your::Module import => [qw(this that)], tests => 23;\n\nsays to import the functions \"this()\" and \"that()\" as well as set the plan to be 23 tests.\n\n\"import()\" also sets the \"exportedto()\" attribute of your builder to be the caller of the\n\"import()\" function.\n\nAdditional behaviors can be added to your \"import()\" method by overriding \"importextra()\".\n\nimportextra\nYour::Module->importextra(\\@importargs);\n\n\"importextra()\" is called by \"import()\". It provides an opportunity for you to add behaviors to\nyour module based on its import list.\n\nAny extra arguments which shouldn't be passed on to \"plan()\" should be stripped off by this\nmethod.\n\nSee Test::More for an example of its use.\n\nNOTE This mechanism is *VERY ALPHA AND LIKELY TO CHANGE* as it feels like a bit of an ugly hack\nin its current form.\n"
                },
                {
                    "name": "Builder",
                    "content": "Test::Builder::Module provides some methods of getting at the underlying Test::Builder object.\n\nbuilder\nmy $builder = Your::Class->builder;\n\nThis method returns the Test::Builder object associated with Your::Class. It is not a\nconstructor so you can call it as often as you like.\n\nThis is the preferred way to get the Test::Builder object. You should *not* get it via\n\"Test::Builder->new\" as was previously recommended.\n\nThe object returned by \"builder()\" may change at runtime so you should call \"builder()\" inside\neach function rather than store it in a global.\n\nsub ok {\nmy $builder = Your::Class->builder;\n\nreturn $builder->ok(@);\n}\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "Test2::Manual::Tooling::TestBuilder describes the improved options for writing testing modules\nprovided by Test2.\n",
            "subsections": []
        }
    },
    "summary": "Test::Builder::Module - Base class for test modules",
    "flags": [],
    "examples": [],
    "see_also": []
}