{"id":19422865,"url":"https://github.com/dutchcodingcompany/parameterized_test","last_synced_at":"2026-04-01T18:42:25.432Z","repository":{"id":43798756,"uuid":"429085900","full_name":"DutchCodingCompany/parameterized_test","owner":"DutchCodingCompany","description":"Simple package that helps with executing parameterized tests. Inspired by JUnit ParameterizedTest CsvValues.","archived":false,"fork":false,"pushed_at":"2024-12-23T03:41:12.000Z","size":182,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T10:26:06.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DutchCodingCompany.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-11-17T14:48:18.000Z","updated_at":"2024-08-16T10:07:17.000Z","dependencies_parsed_at":"2024-03-05T09:43:26.982Z","dependency_job_id":"ef464875-72fa-4c0a-a4db-1795f79f50db","html_url":"https://github.com/DutchCodingCompany/parameterized_test","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Fparameterized_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Fparameterized_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Fparameterized_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DutchCodingCompany%2Fparameterized_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DutchCodingCompany","download_url":"https://codeload.github.com/DutchCodingCompany/parameterized_test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250654502,"owners_count":21465895,"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":[],"created_at":"2024-11-10T13:35:33.044Z","updated_at":"2026-03-27T02:05:25.253Z","avatar_url":"https://github.com/DutchCodingCompany.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nThis README describes the package. If you publish this package to pub.dev,\nthis README's contents appear on the landing page for your package.\n\nFor information about how to write a good package README, see the guide for\n[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).\n\nFor general information about developing packages, see the Dart guide for\n[creating packages](https://dart.dev/guides/libraries/create-library-packages)\nand the Flutter guide for\n[developing packages and plugins](https://flutter.dev/developing-packages).\n--\u003e\n\n# 🧪 Parameterized test\n\nSupercharge your Dart testing with **parameterized_test**! Built on top of the [dart test package](https://pub.dev/packages/test), this [JUnit ParameterizedTest](https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests) inspired package wrap around `group` and `test` to take your testing to the next level!\n\n## Table of contents\n- [Features](#features-)\n- [Installation](#installation-)\n- [Usage](#usage-)\n- [Examples](#examples-)\n- [Additional information](#additional-information-)\n\n## Features ✨\n\n- ✅ Run a test multiple times based on provided parameter list.\n- ✅ Built on top of [dart test package](https://pub.dev/packages/test).\n- ✅ Type cast test parameters used in the tests.\n- ✅ Include test options for parameter_test.\n- ✅ Include test options per parameter.\n\n## Installation 🛠\n\n```yaml\ndev_dependencies:\n  parameterized_test: [latest-version]\n```\n\n## Usage ⚡️\n\nInstead of creating a `group` test with multiple of the same `test` and different parameters, you can now use `parameterizedTest` and supply it list of test parameters to run the same test with multiple times.\nSpecifying a parameterized test is almost the same as normal test. It has all the same parameters as a normal test like: `skip` or `testOn` etc. \nThe only difference is that you need to provide a list of test values and a function that takes the same amount of arguments as the test values.\n\nFor example:\n```dart\nparameterizedTest(\n  'Fruit name matches length',\n  // List of values to test\n  [\n  // parameters for the test\n    ['kiwi', 4],\n    ['apple', 5],\n    ['banana', 6],\n    ['pineapple', 9],\n  ],\n  // Test function accepting the provided parameters\n  (String fruit, int length) {\n    expect(fruit.length, length);\n  },\n);\n```\nThis `parameterizedTest` will create a `group` with 4 `test` inside it. Each test will run the test function with the provided parameters.\n```\n- Fruit name matches length     (group)\n    - [ 'kiwi', 4 ]             (test)\n    - [ 'apple', 5 ]            (test)\n    - [ 'banana', 6 ]           (test)\n    - [ 'pineapple', 9 ]        (test)\n```\n\nThere is also a `parameterizedGroup` which is basically the same as `parameterizedTest` but instead of creating a `group` that runs a `test` multiple times, it creates a `group` that runs a `group` multiple times.\nHere you still need to provide a `test`. This can be useful if you want to have nested groups of tests.\n\nBesides accepting a list of test values, you can also provide a `setUp` and `tearDown` function to run before and after each test.\n\n### Add test options to parameter 🔩\nIf you want to add test options to a specific parameter you can do so by using the `options` extension on `List`. This will allow you to add test options like `skip` or `testOn` to a specific parameter.\n\nFor example:\n```dart\nparameterizedTest(\n  'Fruit name matches length',\n  // List of values to test\n  [\n  // parameters for the test\n    ['kiwi', 4],\n    ['apple', 5].options(skip: 'Apple is not ripe yet'),\n    ['banana', 6],\n    ['pineapple', 9],\n  ],\n  // Test function accepting the provided parameters\n  (String fruit, int length) {\n    expect(fruit.length, length);\n  },\n);\n```\n\nThis will create a `group` with 4 `test` inside it. The second test will receive the provided test options and will be skipped in this case.\n\n### Changing test description output 📝\nBy default, the test description contains the test value used within the tests. you can override this by using `customDescriptionBuilder`.\n\nWhen normally running parameterized tests with description 'My parameterized test' and the values `[['first', 'second', true], ['third', 'fourth', false]]` the test description output looks something like this:\n```\nMy parameterized test [ 'first', 'second', true ]\nMy parameterized test [ 'third', 'fourth', false ]\n```\n\nWhen defining a `customDescriptionBuilder` like this:\n```dart\n...\ncustomDiscriptionBuilder: (groupDescription, index, values) =\u003e '🚀[$index] $groupDescription: \u003c\u003c${values.join('|')}\u003e\u003e',\n...\n```\n\nThe output will look like this:\n```\nMy parameterized test 🚀[1] My parameterized test: \u003c\u003cfirst|second|true\u003e\u003e\nMy parameterized test 🚀[2] My parameterized test: \u003c\u003cthird|fourth|false\u003e\u003e\n```\n\n\u003eNote: the first 'My parameterized test' is because parameterized tests make use of a group test. Most IDE's will group this for you and only show the second part.\n\n## Examples 📦\n### Simple test containing a list of single values\n```dart\nparameterizedTest(\n  'Example of list of single values',\n  [\n    1,\n    2,\n    3,\n  ],\n  (int value) {\n    final result = value \u003c 4;\n    expect(result, true);\n  },\n);\n```\n\n### Simple test containing a list of multiple values\n```dart\nparameterizedTest('Example of list of multiple values', [\n    [0, 1, 1],\n    [1, 1, 2],\n    [1, 2, 3],\n    [2, 2, 4],\n  ], (int value1, int value2, int sum) {\n    expect(value1 + value2, sum);\n});\n```\n### Test containing a list with complex objects\n```dart\nparameterizedTest('Example of a list with complex object', [\n    [DateTime(2024, 4, 12), 5],\n    [DateTime(1969, 07, 20), 7],\n  ], (DateTime dateTime, int expectedWeekday) {\n    expect(dateTime.weekday, expectedWeekday);\n});\n```\n\n### Test containing a list of enums\n```dart\nenum TestEnum {\n  one(3),\n  two(3),\n  three(5);\n\n  const TestEnum(this.myLength);\n\n  final int myLength;\n}\n\nparameterizedTest(\n  'Example using enum as value',\n  TestEnum.values,\n  (TestEnum testEnum) {\n    expect(testEnum.name.length, testEnum.myLength);\n  },\n);\n```\n### Test retreiving the list of values from a function\n```dart\nList\u003cdynamic\u003e provideData() {\n  return [\n          [0, 1, 1],\n          [1, 1, 2],\n          [1, 2, 3],\n          [2, 2, 4],\n         ];\n}\n\nparameterizedTest(\n  'Example of list of values from function',\n  provideData(),\n  (int value1, int value2, int sum) {\n    expect(value1 + value2, sum);\n  },\n);\n```\n\n### Simple test with setup and teardown\n```dart\nparameterizedTest(\n  'Example with setup and teardown ',\n  [\n    ['kiwi', 4],\n    ['apple', 5],\n    ['banana', 6],\n  ],\n  (String word, int length) {\n    expect(word.length, length);\n  },\n  setUp: () {\n    print('Setup everything I need for testing');\n  },\n  tearDown: () {\n    print('tear it down again');\n  },\n);\n```\n\n ### Test which is an async test\n ```dart\nparameterizedTest(\n  'Example using a async test',\n  [\n    100,\n    200,\n    300,\n  ],\n  (int value) async {\n    final millis = DateTime.now().millisecondsSinceEpoch;\n    await Future\u003cvoid\u003e.delayed(Duration(milliseconds: value));\n    final passed = DateTime.now().millisecondsSinceEpoch - millis;\n  \n    expect(passed \u003e= value, true);\n  },\n);\n```\n\u003e Note: This is a example test to showcase async tests are also possible.\n\u003e But this is not a good practice to use a delay like\n\u003e this in a test. Running this test will take longer. This could be\n\u003e fixed by using a package like [fake_async](https://pub.dev/packages/fake_async).\n\n### Test with CSV data\nIts also possible to combine parameterizedTest for example with the [csv](https://pub.dev/packages/csv) package.\n\n```dart\nparameterizedTest('Example of CSV data',\n  const CsvToListConverter().convert('kiwi,4\\r\\napple,5\\r\\nbanana,6'),\n  (String fruit, int length) {\n    expect(fruit.length, length);\n});\n```\n\n### Testing with `Future.error` values\nWhen using `Future.error` directly in your parameterized test values, this might lead to not executing tests at all. In order to handle this correctly your can provide the `Future` as a callback function.  \nBut also need to make sure that the when the future is awaited its also catch. `Future.error` will throw the provided object. See [23](https://github.com/DutchCodingCompany/parameterized_test/issues/23) for more information.\n\n## Additional information 💡\n\nIt's just a simple wrapper to easily execute tests multiple times with different values. Feel free to\nleave some feedback or open a pull request :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchcodingcompany%2Fparameterized_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdutchcodingcompany%2Fparameterized_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchcodingcompany%2Fparameterized_test/lists"}