Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# 2.0.2
## 2.0.3
- Added guard clause in `extractFunctionArgumentsSignature` to prevent `RangeError` on unexpected error formats.
- Exported `CustomDescriptionBuilder`.
- Fixed typo `customDiscriptionBuilder` in documentation.
- Fixed truncated doc comment on `ListTestParametersEx`.
- Removed duplicate test.
- Fixed minor typos in documentation and tests.
- added a skill for writing parameterized tests

## 2.0.2
- Update dependencies
- Update `very_good_analysis` to `10.0.0`
- Update `test` to `1.26.2`
Expand Down Expand Up @@ -40,7 +49,7 @@ parameterizedTest('No more numbered function!', [
[3, 4],
],
(int a, int b) => expect(a+b, isPositive),
customDiscriptionBuilder: (groupDescription, index, values) => '🚀[$index] $groupDescription: <<${values.join('|')}>>',
customDescriptionBuilder: (groupDescription, index, values) => '🚀[$index] $groupDescription: <<${values.join('|')}>>',
);
```

Expand All @@ -65,7 +74,7 @@ Test with custom description 🚀[2] Test with custom description: <<3|4>>

## 1.0.0

Major rework on `paramterized_test` which includes:
Major rework on `parameterized_test` which includes:

- DISCONTINUED `parameterized_source` package
- DEPRECATED `ParameterizedSource.csv`
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Dutch Coding Company B.V.
Copyright (c) 2026 Dutch Coding Company B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ My parameterized test [ 'third', 'fourth', false ]
When defining a `customDescriptionBuilder` like this:
```dart
...
customDiscriptionBuilder: (groupDescription, index, values) => '🚀[$index] $groupDescription: <<${values.join('|')}>>',
customDescriptionBuilder: (groupDescription, index, values) => '🚀[$index] $groupDescription: <<${values.join('|')}>>',
...
```

Expand Down Expand Up @@ -181,7 +181,7 @@ parameterizedTest(
},
);
```
### Test retreiving the list of values from a function
### Test retrieving the list of values from a function
```dart
List<dynamic> provideData() {
return [
Expand Down Expand Up @@ -250,7 +250,7 @@ Its also possible to combine parameterizedTest for example with the [csv](https:

```dart
parameterizedTest('Example of CSV data',
const CsvToListConverter().convert('kiwi,4\r\napple,5\r\nbanana,6'),
Csv(dynamicTyping: true).decode('kiwi,4\r\napple,5\r\nbanana,6'),
(String fruit, int length) {
expect(fruit.length, length);
});
Expand Down
6 changes: 3 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ include: package:very_good_analysis/analysis_options.yaml
formatter:
trailing_commas: automate

linter:
rules:
require_trailing_commas: false
analyzer:
errors:
unawaited_futures: warning
avoid_void_async: warning
missing_return: error
missing_required_param: error
invalid_annotation_target: info

language:
strict-casts: true
Expand Down
2 changes: 1 addition & 1 deletion example/parameterized_test_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void main() {
// Test with CSV data
parameterizedTest(
'Example of CSV data',
const CsvToListConverter().convert('kiwi,4\r\napple,5\r\nbanana,6'),
Csv(dynamicTyping: true).decode('kiwi,4\r\napple,5\r\nbanana,6'),
(String fruit, int length) {
expect(fruit.length, length);
},
Expand Down
2 changes: 2 additions & 0 deletions lib/parameterized_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ library;
export '/src/parameterized_test.dart'
show parameterizedGroup, parameterizedTest;
export '/src/test_options/test_options_ext.dart';
export '/src/test_options/value_with_test_options.dart'
show CustomDescriptionBuilder;
5 changes: 5 additions & 0 deletions lib/src/errors/parameterized_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ class ParameterizedError extends Error {
static String extractFunctionArgumentsSignature(String body) {
const closure = 'Closure: (';
final closureIndex = body.indexOf(closure);

if (closureIndex == -1) return body;

final endIndex = body.indexOf(')', closureIndex);

if (endIndex == -1) return body;

final bodyClosure = body.substring(closureIndex + closure.length, endIndex);

return bodyClosure.replaceAll(RegExp('<(.*)>'), '');
Expand Down
1 change: 0 additions & 1 deletion lib/src/parameterized_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ class ParameterizedTestImpl implements ParameterizedTest {

/// Unpack wrapped values and test options.
/// Handle different types of values.
// ignore: switch_on_type
ValueWithTestOptions parseValues(dynamic value) => switch (value) {
ValueWithTestOptions() => value,
List() => (values: value, testOptions: null),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/test_options/test_options_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:parameterized_test/src/test_options/test_options.dart';
import 'package:parameterized_test/src/test_options/value_with_test_options.dart';
import 'package:test/test.dart' as dart_test;

/// Extension on [List] to apply extra test options for a specified
/// Extension on [List] to apply extra test options for a specified test value.
extension ListTestParametersEx<T extends List<dynamic>> on T {
/// Applied extra test options for a specified test value.
/// For example:
Expand Down
2 changes: 1 addition & 1 deletion lib/src/test_options/value_with_test_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:parameterized_test/src/test_options/test_options.dart';
///
/// For example:
/// ```dart
/// customDiscriptionBuilder: (groupDescription, index, values) =>
/// customDescriptionBuilder: (groupDescription, index, values) =>
/// '🚀[$index] $groupDescription: <<${values.join('|')}>>',
/// ```
/// {@endtemplate}
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: parameterized_test
description: Run a test multiple times based on provided parameter list. Inspired by JUnit ParameterizedTest.
version: 2.0.2
homepage: https://www.github.com/DutchCodingCompany/parameterized_test
version: 2.0.3
repository: https://www.github.com/DutchCodingCompany/parameterized_test
topics: [test, testing, parameterized]

environment:
Expand All @@ -10,8 +10,8 @@ environment:
dependencies:
meta: ^1.16.0
stack_trace: ^1.12.1
test: ^1.26.2
test: ^1.28.0

dev_dependencies:
csv: ^6.0.0
very_good_analysis: ^10.0.0
csv: ^8.0.0
very_good_analysis: ^10.2.0
Loading
Loading