{
    "mode": "perldoc",
    "parameter": "Test::Unit::TestSuite",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Test%3A%3AUnit%3A%3ATestSuite/json",
    "generated": "2026-06-10T13:42:47Z",
    "synopsis": "package MySuite;\nuse base qw(Test::Unit::TestSuite);\nsub name { 'My very own test suite' }\nsub includetests { qw(MySuite1 MySuite2 MyTestCase1 ...) }\nThis is the easiest way of building suites; there are many more. Read on ...",
    "sections": {
        "NAME": {
            "content": "Test::Unit::TestSuite - unit testing framework base class\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package MySuite;\n\nuse base qw(Test::Unit::TestSuite);\n\nsub name { 'My very own test suite' }\nsub includetests { qw(MySuite1 MySuite2 MyTestCase1 ...) }\n\nThis is the easiest way of building suites; there are many more. Read on ...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This class provides the functionality for building test suites in several different ways.\n\nAny module can be a test suite runnable by the framework if it provides a \"suite()\" method which\nreturns a \"Test::Unit::TestSuite\" object, e.g.\n\nuse Test::Unit::TestSuite;\n\n# more code here ...\n\nsub suite {\nmy $class = shift;\n\n# Create an empty suite.\nmy $suite = Test::Unit::TestSuite->emptynew(\"A Test Suite\");\n# Add some tests to it via $suite->addtest() here\n\nreturn $suite;\n}\n\nThis is useful if you want your test suite to be contained in the module it tests, for example.\n\nAlternatively, you can have \"standalone\" test suites, which inherit directly from\n\"Test::Unit::TestSuite\", e.g.:\n\npackage MySuite;\n\nuse base qw(Test::Unit::TestSuite);\n\nsub new {\nmy $class = shift;\nmy $self = $class->SUPER::emptynew();\n# Build your suite here\nreturn $self;\n}\n\nsub name { 'My very own test suite' }\n\nor if your \"new()\" is going to do nothing more interesting than add tests from other suites and\ntestcases via \"addtest()\", you can use the \"includetests()\" method as shorthand:\n\npackage MySuite;\n\nuse base qw(Test::Unit::TestSuite);\n\nsub name { 'My very own test suite' }\nsub includetests { qw(MySuite1 MySuite2 MyTestCase1 ...) }\n\nThis is the easiest way of building suites.\n",
            "subsections": []
        },
        "CONSTRUCTORS": {
            "content": "emptynew ([NAME])\nmy $suite = Test::Unit::TestSuite->emptynew('my suite name');\n\nCreates a fresh suite with no tests.\n\nnew ([ CLASSNAME | TEST ])\nIf a test suite is provided as the argument, it merely returns that suite. If a test case is\nprovided, it extracts all test case methods from the test case (see \"listtests\" in\nTest::Unit::TestCase) into a new test suite.\n\nIf the class this method is being run in has an \"includetests\" method which returns an array of\nclass names, it will also automatically add the tests from those classes into the newly\nconstructed suite object.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "name()\nReturns the suite's human-readable name.\n\nnames()\nReturns an arrayref of the names of all tests in the suite.\n\nlist (SHOWTESTCASES)\nProduces a human-readable indented lists of the suite and the subsuites it contains. If the\nfirst parameter is true, also lists any testcases contained in the suite and its subsuites.\n\naddtest (TESTCLASSNAME | TESTOBJECT)\nYou can add a test object to a suite with this method, by passing either its classname, or the\nobject itself as the argument.\n\nOf course, there are many ways of getting the object too ...\n\n# Get and add an existing suite.\n$suite->addtest('MySuite1');\n\n# This is exactly equivalent:\n$suite->addtest(Test::Unit::TestSuite->new('MySuite1'));\n\n# So is this, provided MySuite1 inherits from Test::Unit::TestSuite.\nuse MySuite1;\n$suite->addtest(MySuite1->new());\n\n# Extract yet another suite by way of suite() method and add it to\n# $suite.\nuse MySuite2;\n$suite->addtest(MySuite2->suite());\n\n# Extract test case methods from MyModule::TestCase into a\n# new suite and add it to $suite.\n$suite->addtest(Test::Unit::TestSuite->new('MyModule::TestCase'));\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Copyright (c) 2000-2002, 2005 the PerlUnit Development Team (see Test::Unit or the AUTHORS file\nincluded in this distribution).\n\nAll rights reserved. This program is free software; you can redistribute it and/or modify it\nunder the same terms as Perl itself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "*   Test::Unit::TestRunner\n\n*   Test::Unit::TkTestRunner\n\n*   For further examples, take a look at the framework self test collection (t::tlib::AllTests).\n",
            "subsections": []
        }
    },
    "summary": "Test::Unit::TestSuite - unit testing framework base class",
    "flags": [],
    "examples": [],
    "see_also": []
}