Skip to content

Commit

Permalink
fix(test): test_runner runs tests in isolated groups (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel committed Mar 21, 2022
1 parent 7487f21 commit 5d01936
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Future<void> _flutterTest({
final timeElapsed = Duration(milliseconds: event.time).formatted();
final stats = computeStats();
final testName = test.name.truncated(
_lineLength - (timeElapsed.length + stats.length + 3),
_lineLength - (timeElapsed.length + stats.length + 2),
);
stdout('''$clearLine$timeElapsed $stats: $testName''');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/commands/test/templates/test_runner_bundle.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions test/src/cli/flutter_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ void main() {
});
}''';

const extraLongTestNameContents = '''
import 'package:test/test.dart';
void main() {
test('reeeeeaaaaalllllllllyyyyyyyyyyyloooonnnnnnngggggggggtestttttttttttttttnameeeeeeeeeeeeeeeee', () {
expect(true, isTrue);
});
test('extraaaaaareeeeeaaaaalllllllllyyyyyyyyyyyloooonnnnnnngggggggggtestttttttttttttttnameeeeeeeeeeeeeeeee', () {
expect(true, isFalse);
});
test('superrrrrrrextraaaaaareeeeeaaaaalllllllllyyyyyyyyyyyloooonnnnnnngggggggggtestttttttttttttttnameeeeeeeeeeeeeeeee', () {
expect(true, isFalse);
}, skip: true);
}''';

const loggingTestContents = '''
import 'package:test/test.dart';
Expand Down Expand Up @@ -503,6 +520,41 @@ void main() {
).called(1);
});

test('completes and truncates extra long test name', () async {
final directory = Directory.systemTemp.createTempSync();
final testDirectory = Directory(p.join(directory.path, 'test'))
..createSync();
File(p.join(directory.path, 'pubspec.yaml')).writeAsStringSync(pubspec);
File(
p.join(testDirectory.path, 'example_test.dart'),
).writeAsStringSync(extraLongTestNameContents);
await expectLater(
Flutter.test(
cwd: directory.path,
stdout: logger.write,
stderr: logger.err,
),
completes,
);
verify(
() => logger.write(
any(
that: contains(
'Running "flutter test" in ${p.dirname(directory.path)}',
),
),
),
).called(1);
verify(
() => logger.write(any(that: contains('+1: ...'))),
).called(1);
verify(
() => logger.write(
any(that: contains('+1 -1 ~1: Some tests failed.')),
),
).called(1);
});

test('completes when there is a test directory w/out stdout,stderr', () {
final directory = Directory.systemTemp.createTempSync();
final testDirectory = Directory(p.join(directory.path, 'test'))
Expand Down

0 comments on commit 5d01936

Please sign in to comment.