Skip to content

Commit 5d01936

Browse files
authored
fix(test): test_runner runs tests in isolated groups (#329)
1 parent 7487f21 commit 5d01936

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

lib/src/cli/flutter_cli.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ Future<void> _flutterTest({
305305
final timeElapsed = Duration(milliseconds: event.time).formatted();
306306
final stats = computeStats();
307307
final testName = test.name.truncated(
308-
_lineLength - (timeElapsed.length + stats.length + 3),
308+
_lineLength - (timeElapsed.length + stats.length + 2),
309309
);
310310
stdout('''$clearLine$timeElapsed $stats: $testName''');
311311
}

lib/src/commands/test/templates/test_runner_bundle.dart

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/src/cli/flutter_cli_test.dart

+52
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,23 @@ void main() {
6969
});
7070
}''';
7171

72+
const extraLongTestNameContents = '''
73+
import 'package:test/test.dart';
74+
75+
void main() {
76+
test('reeeeeaaaaalllllllllyyyyyyyyyyyloooonnnnnnngggggggggtestttttttttttttttnameeeeeeeeeeeeeeeee', () {
77+
expect(true, isTrue);
78+
});
79+
80+
test('extraaaaaareeeeeaaaaalllllllllyyyyyyyyyyyloooonnnnnnngggggggggtestttttttttttttttnameeeeeeeeeeeeeeeee', () {
81+
expect(true, isFalse);
82+
});
83+
84+
test('superrrrrrrextraaaaaareeeeeaaaaalllllllllyyyyyyyyyyyloooonnnnnnngggggggggtestttttttttttttttnameeeeeeeeeeeeeeeee', () {
85+
expect(true, isFalse);
86+
}, skip: true);
87+
}''';
88+
7289
const loggingTestContents = '''
7390
import 'package:test/test.dart';
7491
@@ -503,6 +520,41 @@ void main() {
503520
).called(1);
504521
});
505522

523+
test('completes and truncates extra long test name', () async {
524+
final directory = Directory.systemTemp.createTempSync();
525+
final testDirectory = Directory(p.join(directory.path, 'test'))
526+
..createSync();
527+
File(p.join(directory.path, 'pubspec.yaml')).writeAsStringSync(pubspec);
528+
File(
529+
p.join(testDirectory.path, 'example_test.dart'),
530+
).writeAsStringSync(extraLongTestNameContents);
531+
await expectLater(
532+
Flutter.test(
533+
cwd: directory.path,
534+
stdout: logger.write,
535+
stderr: logger.err,
536+
),
537+
completes,
538+
);
539+
verify(
540+
() => logger.write(
541+
any(
542+
that: contains(
543+
'Running "flutter test" in ${p.dirname(directory.path)}',
544+
),
545+
),
546+
),
547+
).called(1);
548+
verify(
549+
() => logger.write(any(that: contains('+1: ...'))),
550+
).called(1);
551+
verify(
552+
() => logger.write(
553+
any(that: contains('+1 -1 ~1: Some tests failed.')),
554+
),
555+
).called(1);
556+
});
557+
506558
test('completes when there is a test directory w/out stdout,stderr', () {
507559
final directory = Directory.systemTemp.createTempSync();
508560
final testDirectory = Directory(p.join(directory.path, 'test'))

0 commit comments

Comments
 (0)