Skip to content

Commit f8a208c

Browse files
authored
Merge pull request #13 from DutchCodingCompany/feature/improve_blank_input
✨ Display empty and blank lines during tests
2 parents d012576 + 6d3dfa3 commit f8a208c

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed

lib/src/test_options/value_with_test_options.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ class ValueWithTestOptions extends Iterable<dynamic> {
77
final Iterable<dynamic> value;
88
final TestOptions testOptions;
99

10+
String get description =>
11+
'[ ${value.map((e) => e is String ? '\'$e\'' : e.toString()).join(', ')} ]';
12+
1013
@override
1114
Iterator<dynamic> get iterator => value.iterator;
1215

1316
GroupTestOptions get toGroupOptions => GroupTestOptions(
14-
description: '$value',
17+
description: description,
1518
skip: testOptions.skip,
1619
onPlatform: testOptions.onPlatform,
1720
retry: testOptions.retry,

lib/src/util/test_value_helpers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ void mapTests(
88
dynamic Function(Iterable<dynamic>) body,
99
) {
1010
for (final ValueWithTestOptions value in values) {
11-
value.testOptions.test('$value', () {
11+
value.testOptions.test(value.description, () {
1212
validityCheck(value, length);
1313
return body(value.value);
1414
});

test/test_options/test_options_ext_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void main() {
5757
expect(
5858
result,
5959
TypeMatcher<GroupTestOptions>()
60-
.having((e) => e.description, 'desciption', '[1, 2, 3]')
60+
.having((e) => e.description, 'desciption', '[ 1, 2, 3 ]')
6161
.having((e) => e.retry, 'retry', 1)
6262
.having((e) => e.onPlatform, 'onPlatform', {'foo': 'bar'})
6363
.having((e) => e.tags, 'tags', 'taggy')
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import 'package:parameterized_test/src/test_options/test_options.dart';
2+
import 'package:parameterized_test/src/test_options/value_with_test_options.dart';
3+
import 'package:test/test.dart';
4+
5+
void main() {
6+
final TestOptions testOptions = TestOptions();
7+
8+
group('description tests', () {
9+
test(
10+
'ValueWithTestOptions with only String values are wrapped with \'quotes\'',
11+
() {
12+
final result = ValueWithTestOptions(
13+
['a', 'b', '', ' '],
14+
testOptions,
15+
).description;
16+
17+
expect(result, "[ 'a', 'b', '', ' ' ]");
18+
});
19+
20+
test(
21+
'ValueWithTestOptions with mixed types only String values are wrapped with \'quotes\'',
22+
() {
23+
final result = ValueWithTestOptions(
24+
['a', 'b', '', ' ', 1, 1.5, true, _ClassWithToString()],
25+
testOptions,
26+
).description;
27+
28+
expect(
29+
result, "[ 'a', 'b', '', ' ', 1, 1.5, true, class with toString ]");
30+
});
31+
});
32+
}
33+
34+
class _ClassWithToString {
35+
@override
36+
String toString() => 'class with toString';
37+
}

test/util/test_value_helpers_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void main() {
6868
executed.add(true);
6969
});
7070

71-
expect(result, ['(1)', '(2)']);
71+
expect(result, ['[ 1 ]', '[ 2 ]']);
7272
expect(executed, [true, true]);
7373
});
7474
});
@@ -133,7 +133,7 @@ void main() {
133133
executed.add(true);
134134
});
135135

136-
expect(result, ['(1, 2)', '(3, 4)']);
136+
expect(result, ['[ 1, 2 ]', '[ 3, 4 ]']);
137137
expect(executed, [true, true]);
138138
});
139139
});

0 commit comments

Comments
 (0)