{"id":16315161,"url":"https://github.com/robrwo/test-roo-datadriven","last_synced_at":"2026-02-03T09:02:00.441Z","repository":{"id":56834658,"uuid":"112746045","full_name":"robrwo/Test-Roo-DataDriven","owner":"robrwo","description":"Use data-driven test files with Test-Roo","archived":false,"fork":false,"pushed_at":"2024-12-31T14:33:32.000Z","size":74,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-06T10:18:05.063Z","etag":null,"topics":["data-driven-tests","perl-module"],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robrwo.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-01T13:59:36.000Z","updated_at":"2024-12-31T14:33:36.000Z","dependencies_parsed_at":"2025-05-05T19:52:33.609Z","dependency_job_id":"2774909c-ff6d-4d24-8b6a-4bc078ec7f6d","html_url":"https://github.com/robrwo/Test-Roo-DataDriven","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/robrwo/Test-Roo-DataDriven","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FTest-Roo-DataDriven","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FTest-Roo-DataDriven/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FTest-Roo-DataDriven/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FTest-Roo-DataDriven/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robrwo","download_url":"https://codeload.github.com/robrwo/Test-Roo-DataDriven/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FTest-Roo-DataDriven/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29039341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T08:41:49.363Z","status":"ssl_error","status_checked_at":"2026-02-03T08:40:19.255Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data-driven-tests","perl-module"],"created_at":"2024-10-10T21:56:23.246Z","updated_at":"2026-02-03T09:02:00.426Z","avatar_url":"https://github.com/robrwo.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nTest::Roo::DataDriven - simple data-driven tests with Test::Roo\n\n# VERSION\n\nversion v0.4.3\n\n# SYNOPSIS\n\n```perl\npackage MyTests\n\nuse Test::Roo;\n\nuse lib 't/lib';\n\nwith qw/\n  MyClass::Test::Role\n  Test::Roo::DataDriven\n  /;\n\n1;\n\npackage main;\n\nuse Test::More;\n\nMyTests-\u003erun_data_tests(\n  files   =\u003e 't/data/myclass',\n  recurse =\u003e 1,\n);\n\ndone_testing;\n```\n\n# DESCRIPTION\n\nThis class extends [Test::Roo](https://metacpan.org/pod/Test%3A%3ARoo) for data-driven tests that are kept in\nseparate files.\n\nThis is useful when a test script has too many test cases, so that it\nis impractical to include all of the cases in a single test script.\n\nIt allows different tests to share the test cases.\n\nIt also makes it easier to have testers with very little Perl\nknowledge to write tests.\n\n# METHODS\n\n## `run_data_tests`\n\nThis is called as a class method, and is a wrapper around  the `run_tests`\nmethod.  It takes the following arguments:\n\n- `files`\n\n    This is a path or array reference to a list of paths that contain test\n    cases.\n\n    If a path is a directory, then all test cases in that directory will\n    be tested.\n\n    The files are expected to be executable Perl snippets that return a\n    hash reference or an array reference of hash references.  The keys\n    should correspond to the attributes of the [Test::Roo](https://metacpan.org/pod/Test%3A%3ARoo) class.\n\n    See [\"Data Files\"](#data-files) below.\n\n- `recurse`\n\n    When this is true, then any directories in [\"files\"](#files) will be checked\n    recursively.\n\n    It is false by default.\n\n    item `follow_symlinks`\n\n    When this is true, then symlinks in [\"files\"](#files) will be followed.\n\n    It is false by default.\n\n- `match`\n\n    A regular expression to match the names of data files. It defaults to\n    `qr/\\.dat$/`.\n\n- `filter`\n\n    This is a reference to a subroutine that takes a single test case as a\n    hash reference, as well as the data file ([Path::Tiny](https://metacpan.org/pod/Path%3A%3ATiny)) and case\n    index in that file.\n\n    The subroutine is expected to return a hash reference to a test case.\n\n    For example, if you wanted to add the data file and index, you might\n    use\n\n    ```perl\n    MyTests-\u003erun_data_tests(\n      filter = sub {\n          my ($test, $file, $index) = @_;\n          my %args = (\n              %$test,                # avoid side-effects\n              data_file  =\u003e \"$file\", # stringify Path::Tiny\n              data_index =\u003e $index,  # undef if none\n          );\n          return \\%args;\n      },\n      ...\n    );\n    ```\n\n- `parser`\n\n    By default, the data files are Perl snippets. If the data files exist\n    in a different format, then an alternative parser can be used.\n\n    For example, if the data files were in JSON format:\n\n    ```perl\n    MyTests-\u003erun_data_tests(\n      match  =\u003e qr/\\.json$/,\n      parser =\u003e sub { decode_json( $_[0]-\u003eslurp_raw ) },\n    );\n    ```\n\n    Note that the argument is a [Path::Tiny](https://metacpan.org/pod/Path%3A%3ATiny) object.\n\n    See the [\"parse\\_data\\_file\"](#parse_data_file) method.\n\n    Added in v0.2.0.\n\n- `argv`\n\n    If any arguments are passed on the command line, then they are assumed\n    to be directories are test files. Those will be tested instead of the\n    [\"files\"](#files) parameter.\n\n    This allows you to run tests on specific data files or directories.\n\n    For example,\n\n    ```\n    prove -lv t/01-example.t :: t/data/002-another.dat\n    ```\n\n    This is enabled by default, but requires [App::Prove](https://metacpan.org/pod/App%3A%3AProve).\n\n    Added in v0.2.3.\n\n## `parse_data_file`\n\n```perl\nmy $data = $class-\u003eparse_data_file( $file );\n```\n\nThis is the default parser for the [\"Data Files\"](#data-files).\n\nAdded in v0.2.0.\n\n### Data Files\n\nUnless the default [\"parser\"](#parser) is changed, the data files are simple\nPerl scripts that return a hash reference (or array reference of hash\nreferences) of constructor values for the [Test::Roo](https://metacpan.org/pod/Test%3A%3ARoo) class.\n\nFor example,\n\n```perl\n#!/perl\n\nuse Test::Deep;\n\n+{\n  description =\u003e 'Sample test',\n  params =\u003e {\n    choices =\u003e bag( qw/ first second / ),\n    page    =\u003e 1,\n  },\n};\n```\n\nIn the above example, we are using the `bag` function from\n[Test::Deep](https://metacpan.org/pod/Test%3A%3ADeep), so we have to import the module into our test case to\nensure that it compiles correctly.\n\nNote that there is no performance loss in repeating module imports in\nevery test case. However, you may want to use a module like [ToolSet](https://metacpan.org/pod/ToolSet)\nto import common packages.\n\nData files can contain multiple test cases:\n\n```perl\n#!/perl\n\nuse Test::Deep;\n\n[\n\n  {\n    description =\u003e 'Sample test',\n    params =\u003e {\n      choices =\u003e bag( qw/ first second / ),\n      page    =\u003e 1,\n    },\n  },\n\n  {\n    description =\u003e 'Another test',\n    params =\u003e {\n      choices =\u003e bag( qw/ second third / ),\n      page    =\u003e 2,\n    },\n  },\n\n];\n```\n\nThe data files can also include scripts to generate test cases:\n\n```perl\n#!/perl\n\nsub generate_cases {\n  ...\n};\n\n[\n  generate_cases( page =\u003e 1 ),\n  generate_cases( page =\u003e 2 ),\n];\n```\n\nEach data file is loaded into a unique namespace. However, there is\nnothing preventing the datafiles from modifying variables in other\nnamespaces, or even doing anything else.\n\nIf the data file is successfully parsed, then the namespace is\nunloaded.\n\n# KNOWN ISSUES\n\nSee also [\"BUGS\"](#bugs) below.\n\n## Skipping test cases\n\nSkipping a test case in your test class as per [Test::Roo::Cookbook](https://metacpan.org/pod/Test%3A%3ARoo%3A%3ACookbook),\ne.g.\n\n```perl\nsub BUILD {\n  my ($self) = @_;\n\n  ...\n\n  plan skip_all =\u003e \"Cannot test\" if $some_condition;\n\n}\n```\n\nwill stop all remaining tests from running.\n\nInstead, skip tests before the setup:\n\n```perl\nbefore setup =\u003e sub {\n  my ($self) = @_;\n\n  ...\n\n  plan skip_all =\u003e \"Cannot test\" if $some_condition;\n\n};\n```\n\n## Prerequisite Scanners\n\nPrerequisite scanners used for build tools may not recognise modules\nused in the [\"Data Files\"](#data-files).  To work around this, use the modules as\nwell in the test class or explicitly add them to the distribution's\nmetadata.\n\n# SEE ALSO\n\n[Test::Roo](https://metacpan.org/pod/Test%3A%3ARoo)\n\n# SOURCE\n\nThe development version is on github at [https://github.com/robrwo/Test-Roo-DataDriven](https://github.com/robrwo/Test-Roo-DataDriven)\nand may be cloned from [git://github.com/robrwo/Test-Roo-DataDriven.git](git://github.com/robrwo/Test-Roo-DataDriven.git)\n\n# BUGS\n\nPlease report any bugs or feature requests on the bugtracker website\n[https://github.com/robrwo/Test-Roo-DataDriven/issues](https://github.com/robrwo/Test-Roo-DataDriven/issues)\n\nWhen submitting a bug or request, please include a test-file or a\npatch to an existing test-file that illustrates the bug or desired\nfeature.\n\n## Reporting Security Vulnerabilities\n\nSecurity issues should not be reported on the bugtracker website. Please see `SECURITY.md` for instructions how to\nreport security vulnerabilities\n\n# AUTHOR\n\nRobert Rothenberg \u003crrwo@cpan.org\u003e\n\nThe initial development of this module was sponsored by Science Photo\nLibrary [https://www.sciencephoto.com](https://www.sciencephoto.com).\n\n# CONTRIBUTORS\n\n- Aaron Crane \u003carc@cpan.org\u003e\n- Mohammad S Anwar \u003cmohammad.anwar@yahoo.com\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2017-2019, 2024 by Robert Rothenberg.\n\nThis is free software, licensed under:\n\n```\nThe Artistic License 2.0 (GPL Compatible)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Ftest-roo-datadriven","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobrwo%2Ftest-roo-datadriven","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Ftest-roo-datadriven/lists"}