parameterized_test 0.0.2 copy "parameterized_test: ^0.0.2" to clipboard
parameterized_test: ^0.0.2 copied to clipboard

outdated

Simple package that helps with executing parameterized tests. Inspired by JUnit ParameterizedTest CsvValues.

Parameterized test #

Simple package that helps with executing parameterized tests. Inspired by JUnit ParameterizedTest CsvValues. This package is a wrapper around groups and test.

Features #

This package helps executing a test multiple times with different parameters. Currently parameters can be specified as:

  • ParameterizedSource.csv
  • ParameterizedSource.value
  • ParameterizedSource.values

When using ParameterizedSource.csv the library tries to parse the values to int, double, bool or String?. If the csv value contains a empty string it will be parsed to null. This parsing can be escaped by wrapping in the values in ' or ".

For example:

Input Output
'banana, 4, apple' 'banana', 4, 'apple'
'banana, 4, ' 'banana', 4, null
'banana, "4", apple' 'banana', '4', 'apple'
'banana, 4, """' 'banana', 4, ''

Getting started #

Include the package in your project.

Usage #

Instead of using groups or test you can now use parameterizedTest and supply it with multiple test parameters.

Csv source example:

parameterizedTest(
  'Amount of letters',
  ParameterizedSource.csv([
    'kiwi, 4',
    'apple, 5',
    'banana, 6',
  ]),
  (List<dynamic> values) {
    final String input = values[0];
    final expected = values[1];

    final actual = input.length;

    expect(actual, expected);
  },
);

Values source example:

  parameterizedTest(
    'Amount of letters',
    ParameterizedSource.values([
      ['kiwi', 4],
      ['apple', 5],
      ['banana', 6],
    ]),
    (List<dynamic> values) {
      final String input = values[0];
      final expected = values[1];

      final actual = input.length;

      expect(actual, expected);
    },
  );

Additional information #

Its just a simple wrapper to easily execute tests multiple times with different values. Feel free to leave some feedback or open an pull request :)

11
likes
0
pub points
76%
popularity

Publisher

verified publisherdutchcodingcompany.com

Simple package that helps with executing parameterized tests. Inspired by JUnit ParameterizedTest CsvValues.

Homepage

License

unknown (license)

Dependencies

meta, test

More

Packages that depend on parameterized_test