Skip to content

Commit e9bfc27

Browse files
author
Abdelaziz GACEMI
committed
fix: fix test report in case of multiline test name
1 parent dc0b59c commit e9bfc27

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

lib/src/cli/flutter_cli.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,9 @@ Future<int> _flutterTest({
398398

399399
final timeElapsed = Duration(milliseconds: event.time).formatted();
400400
final stats = computeStats();
401-
final testName = test.name.truncated(
402-
_lineLength - (timeElapsed.length + stats.length + 2),
403-
);
401+
final testName = test.name.toSingleLine().truncated(
402+
_lineLength - (timeElapsed.length + stats.length + 2),
403+
);
404404
stdout('''$clearLine$timeElapsed $stats: $testName''');
405405
}
406406

@@ -496,6 +496,9 @@ extension on String {
496496
final truncated = substring(length - maxLength, length).trim();
497497
return '...$truncated';
498498
}
499+
500+
String toSingleLine() =>
501+
replaceAll('\n', '').replaceAll(RegExp(r'\s\s+'), ' ');
499502
}
500503

501504
String? _getTraceLocation({

test/fixtures/test_runner_fixtures.dart

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,21 @@ const skipExceptionMessageJsonOuput = [
11201120
'type': 'testStart',
11211121
'time': 2757
11221122
},
1123+
{
1124+
'test': {
1125+
'id': 29,
1126+
'name': '''this is the case of a multiline test name that should '''
1127+
''' be well processed by very_good test ''',
1128+
'suiteID': 4,
1129+
'groupIDs': [16],
1130+
'metadata': {'skip': false, 'skipReason': null},
1131+
'line': 4,
1132+
'column': 3,
1133+
'url': 'file:///my_app/test/counter/view/long_name_test.dart'
1134+
},
1135+
'type': 'testStart',
1136+
'time': 2757
1137+
},
11231138
{
11241139
'testID': 15,
11251140
'result': 'success',
@@ -1401,5 +1416,28 @@ const skipExceptionMessageJsonOuput = [
14011416
'type': 'testDone',
14021417
'time': 4248
14031418
},
1404-
{'success': false, 'type': 'done', 'time': 4266},
1419+
{
1420+
'test': {
1421+
'id': 29,
1422+
'name': '''this is the case of a multiline test name that should '''
1423+
''' be well processed by very_good test ''',
1424+
'suiteID': 4,
1425+
'groupIDs': [16],
1426+
'metadata': {'skip': false, 'skipReason': null},
1427+
'line': 4,
1428+
'column': 3,
1429+
'url': 'file:///my_app/test/counter/view/multiline_test.dart'
1430+
},
1431+
'type': 'testStart',
1432+
'time': 5440
1433+
},
1434+
{
1435+
'testID': 29,
1436+
'result': 'success',
1437+
'skipped': false,
1438+
'hidden': false,
1439+
'type': 'testDone',
1440+
'time': 5449
1441+
},
1442+
{'success': false, 'type': 'done', 'time': 5466},
14051443
];

test/src/cli/flutter_cli_test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ void main() {
503503
'\x1B[2K\r00:04 +5 -1 ~2: CounterView renders current count',
504504
'''\x1B[2K\r00:04 +6 -1 ~2: CounterView calls increment when increment button is tapped''',
505505
'''\x1B[2K\r00:04 +7 -1 ~2: CounterView calls decrement when decrement button is tapped''',
506-
'\x1B[2K\r00:04 +7 -1 ~2: Some tests failed.\n'
506+
'''\x1B[2K\r00:05 +8 -1 ~2: ...tiline test name that should be well processed by very_good test''',
507+
'\x1B[2K\r00:05 +8 -1 ~2: Some tests failed.\n'
507508
]),
508509
);
509510
expect(

0 commit comments

Comments
 (0)