{"id":23900104,"url":"https://github.com/bmarcotte/test-subtest-attribute","last_synced_at":"2026-05-31T16:32:03.080Z","repository":{"id":56839655,"uuid":"111166478","full_name":"bmarcotte/Test-Subtest-Attribute","owner":"bmarcotte","description":"A Perl module to declare subtests using subroutine attributes","archived":false,"fork":false,"pushed_at":"2017-11-27T21:46:33.000Z","size":30,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T09:13:44.835Z","etag":null,"topics":["cpan","perl","perl5","tap","testing"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmarcotte.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-18T01:26:44.000Z","updated_at":"2018-02-22T17:57:59.000Z","dependencies_parsed_at":"2022-08-28T23:30:57.164Z","dependency_job_id":null,"html_url":"https://github.com/bmarcotte/Test-Subtest-Attribute","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarcotte%2FTest-Subtest-Attribute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarcotte%2FTest-Subtest-Attribute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarcotte%2FTest-Subtest-Attribute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarcotte%2FTest-Subtest-Attribute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmarcotte","download_url":"https://codeload.github.com/bmarcotte/Test-Subtest-Attribute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240292387,"owners_count":19778311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpan","perl","perl5","tap","testing"],"created_at":"2025-01-04T19:14:31.148Z","updated_at":"2026-05-31T16:32:03.027Z","avatar_url":"https://github.com/bmarcotte.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    Test::Subtest::Attribute - Declare subtests using subroutine attributes\n\nVERSION\n    version 0.04\n\nSYNOPSIS\n      use Test::More;\n      use Test::Subtest::Attribute qw( subtests );\n\n      sub subtest_foo :Subtest {\n          ok( 1, 'foo is OK' );\n          return 1;\n      }\n\n      sub subtest_bar :Subtest( 'name for bar' ) {\n          ok( 1, 'bar is OK' );\n          return 1;\n      }\n\n      subtests()-\u003erun();\n      done_testing();\n\nDESCRIPTION\n    This module provides a simple way, using a subroutine attribute called\n    \":Subtest\", to declare normal subroutines to be subtests in a test\n    script.\n\n    Subtests are typically declared using a call to the \"subtest()\" function\n    from Test::More, in one of the two following ways:\n\n      subtest 'name1'  =\u003e sub { ... };  # An anonymous sub\n      subtest 'name 2' =\u003e \\\u0026some_named_sub;\n\n    The first way can quickly lead to long anonymous subs that can present\n    issues when looking at stacktraces for debugging, profiling, logging,\n    etc. The second way usually leads to repeating the same, or similar,\n    names for each subtest subroutine, in addition to declaring the sub\n    itself, e.g.:\n\n      subtest 'test_this' =\u003e \\\u0026test_this;\n      subtest 'test_that' =\u003e \\\u0026test_that;\n      ...\n      sub test_this { ... }\n      sub test_that { ... }\n      ...\n\n    This module lets you declare those subtests without calls to the\n    \"subtest()\" function, by simply adding a \":Subtest\" attribute to any\n    subroutine that you'd like to have executed as a subtest, like so:\n\n      sub subtest_name1 :Subtest {\n        ...\n      }\n\n    That declares a subtest named 'name1' (the subtest_ part of the name, if\n    present, is automatically stripped off).\n\n    If you'd like to specify the name of the subtest explicitly, which is\n    handy if you'd like to use a name that includes characters. such as\n    spaces, that aren't allowed in bareword identifiers, you can do so by\n    providing an argument to the \":Subtest\" attribute like so:\n\n      sub some_named_sub :Subtest('name 2') {\n        ...\n      }\n\n    When you're done declaring subtests, you run all the ones you've queued\n    up by calling \"subtests()-\"run()\u003e.\n\n    From this module, most test scripts will only need to use the \":Subtest\"\n    attribute and the \"run()\" method described below. Most of the other\n    methods described below are for more advanced usage, such as in test\n    modules that might want to conditionally add, remove, or otherwise\n    manipulate the subtests managed herein.\n\nMETHODS\n  add\n      subtests()-\u003eadd( coderef =\u003e \\%my_sub );\n\n    Adds a subroutine to the current queue of subtests. This method can\n    accept a number of named arguments.\n\n    name\n        Indicates the name of this particular subtest. If the name isn't\n        unique, it will replace the previously declared subtest with the\n        same name.\n\n    where\n        A value of 'prepend' indicates the subtest should be added to the\n        head of the queue of subtests. A value of 'append' indicates the\n        subtest should be added to the end of the queue of subtests. If not\n        given, the default is to append the subtest.\n\n    coderef\n        A reference to the subroutine (named or anonymous) to eventually\n        call for this subtest.\n\n    package\n        The package from which the subtest should be invoked. Typically,\n        this would be the package that the subroutine lives in. Calling the\n        \"run()\" method with an \"invocant\" argument takes precedence over\n        this. It also appears in the fully qualified subroutine name, if\n        \"run()\" is called in verbose mode. Defaults to \"main\" if not given.\n\n    sub_name\n        The name of the subroutine to call for this subtest. If \"coderef\" is\n        defined, this is only needed for display purposes. If \"coderef\" is\n        not defined, the \"run()\" method will attempt to find a sub with this\n        name that can be called via the \"invocant\" or \"package\" arguments.\n\n  prepend\n      subtests()-\u003eprepend( coderef =\u003e \\%my_sub );\n\n    Adds a subtest to the head of the current queue of subtests. Takes the\n    same arguments as the \"add()\" method, and sets the \"where\" param to\n    \"prepend\".\n\n  append\n      subtests()-\u003eappend( coderef =\u003e \\%my_sub );\n\n    Adds a subtest to the end of the current queue of subtests. Takes the\n    same arguments as the \"add()\" method, and sets the \"where\" param to\n    \"append\".\n\n  remove\n      subtests()-\u003eremove( $name_or_coderef );\n\n    Removes the indicated subtest(s) from the queue. The argument can either\n    be the name or the coderef associated with the subtest.\n\n  get_all\n      subtests()-\u003eget_all();\n\n    Returns a list of all of the subtests currently in the queue.\n\n  run\n      subtests()-\u003erun( %args );\n\n    Runs all of the subtests that are currently in the queue.\n\n    This method can be called with any of the following arguments:\n\n    builder\n        The test builder to use. If none is given, a new Test::Builder\n        instance will be created.\n\n    invocant\n        If given, the subtest subroutines will be invoked via this\n        reference.\n\n        NOTE: When the \":Subtest\" attribute is used, the name of the package\n        that the subroutine appears in will be remembered in the subtest\n        metadata, and that package name will be used if no \"invocant\"\n        argument is given explicitly when calling this method. If that value\n        happens to be undefined for any reason, the package name \"main\" is\n        the default instead.\n\n    verbose_names\n        When given, and set to a true value, subtest names will be displayed\n        with \" [sub name]\" appended. If the package name can be determined,\n        and is not \"main\", the sub name will be fully qualified with such.\n\nFUNCTIONS\n  subtests\n    Returns a handle that can be used to invoke the methods in this module.\n    As such, this is the only function exported by this module.\n\n    Currently, this just returns the name of this package, but, in the\n    future, it could return an object instance.\n\nSEE ALSO\n    Attribute::Handlers Test::Builder\n\nAUTHOR\n    Ben Marcotte \u003cbmarcotte NOSPAM cpan.org\u003e\n\nCOPYRIGHT AND LICENSE\n    This software is copyright (c) 2017 by Ben Marcotte.\n\n    This is free software; you can redistribute it and/or modify it under\n    the same terms as the Perl 5 programming language system itself.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarcotte%2Ftest-subtest-attribute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmarcotte%2Ftest-subtest-attribute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarcotte%2Ftest-subtest-attribute/lists"}