diff --git a/lib/src/cli/flutter_cli.dart b/lib/src/cli/flutter_cli.dart index cda7f55e4..7d12175fb 100644 --- a/lib/src/cli/flutter_cli.dart +++ b/lib/src/cli/flutter_cli.dart @@ -398,9 +398,9 @@ Future _flutterTest({ final timeElapsed = Duration(milliseconds: event.time).formatted(); final stats = computeStats(); - final testName = test.name.truncated( - _lineLength - (timeElapsed.length + stats.length + 2), - ); + final testName = test.name.toSingleLine().truncated( + _lineLength - (timeElapsed.length + stats.length + 2), + ); stdout('''$clearLine$timeElapsed $stats: $testName'''); } @@ -496,6 +496,9 @@ extension on String { final truncated = substring(length - maxLength, length).trim(); return '...$truncated'; } + + String toSingleLine() => + replaceAll('\n', '').replaceAll(RegExp(r'\s\s+'), ' '); } String? _getTraceLocation({ diff --git a/test/fixtures/test_runner_fixtures.dart b/test/fixtures/test_runner_fixtures.dart index 86f851a4c..84dca3822 100644 --- a/test/fixtures/test_runner_fixtures.dart +++ b/test/fixtures/test_runner_fixtures.dart @@ -1120,6 +1120,21 @@ const skipExceptionMessageJsonOuput = [ 'type': 'testStart', 'time': 2757 }, + { + 'test': { + 'id': 29, + 'name': '''this is the case of a multiline test name that should ''' + ''' be well processed by very_good test ''', + 'suiteID': 4, + 'groupIDs': [16], + 'metadata': {'skip': false, 'skipReason': null}, + 'line': 4, + 'column': 3, + 'url': 'file:///my_app/test/counter/view/long_name_test.dart' + }, + 'type': 'testStart', + 'time': 2757 + }, { 'testID': 15, 'result': 'success', @@ -1401,5 +1416,28 @@ const skipExceptionMessageJsonOuput = [ 'type': 'testDone', 'time': 4248 }, - {'success': false, 'type': 'done', 'time': 4266}, + { + 'test': { + 'id': 29, + 'name': '''this is the case of a multiline test name that should ''' + ''' be well processed by very_good test ''', + 'suiteID': 4, + 'groupIDs': [16], + 'metadata': {'skip': false, 'skipReason': null}, + 'line': 4, + 'column': 3, + 'url': 'file:///my_app/test/counter/view/multiline_test.dart' + }, + 'type': 'testStart', + 'time': 5440 + }, + { + 'testID': 29, + 'result': 'success', + 'skipped': false, + 'hidden': false, + 'type': 'testDone', + 'time': 5449 + }, + {'success': false, 'type': 'done', 'time': 5466}, ]; diff --git a/test/src/cli/flutter_cli_test.dart b/test/src/cli/flutter_cli_test.dart index eec8f11c6..8b49ff654 100644 --- a/test/src/cli/flutter_cli_test.dart +++ b/test/src/cli/flutter_cli_test.dart @@ -503,7 +503,8 @@ void main() { '\x1B[2K\r00:04 +5 -1 ~2: CounterView renders current count', '''\x1B[2K\r00:04 +6 -1 ~2: CounterView calls increment when increment button is tapped''', '''\x1B[2K\r00:04 +7 -1 ~2: CounterView calls decrement when decrement button is tapped''', - '\x1B[2K\r00:04 +7 -1 ~2: Some tests failed.\n' + '''\x1B[2K\r00:05 +8 -1 ~2: ...tiline test name that should be well processed by very_good test''', + '\x1B[2K\r00:05 +8 -1 ~2: Some tests failed.\n' ]), ); expect(