Skip to content

Commit

Permalink
feat(#377): list failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Renan Araujo committed May 16, 2022
1 parent bf98f44 commit aa93176
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ Future<int> _flutterTest({

var successCount = 0;
var skipCount = 0;
var failureCount = 0;
final failedTests = <String>[];

String computeStats() {
final passingTests = successCount.formatSuccess();
final failingTests = failureCount.formatFailure();
final failingTests = failedTests.length.formatFailure();
final skippedTests = skipCount.formatSkipped();
final result = [passingTests, failingTests, skippedTests]
..removeWhere((element) => element.isEmpty);
Expand Down Expand Up @@ -347,7 +347,7 @@ Future<int> _flutterTest({
successCount++;
} else {
stderr('$clearLine${test.name} ${suite.path} (FAILED)');
failureCount++;
failedTests.add(test.name);
}

final timeElapsed = Duration(milliseconds: event.time).formatted();
Expand All @@ -366,6 +366,22 @@ Future<int> _flutterTest({
: lightRed.wrap('Some tests failed.')!;

stdout('$clearLine${darkGray.wrap(timeElapsed)} $stats: $summary\n');

if (event.success != true) {
assert(
failedTests.isNotEmpty,
'Invalid state: test event report as faield but no failed tests were gathered',
);
final title = styleBold.wrap('Failing Tests:');
final lines = failedTests.fold<StringBuffer>(
StringBuffer('$clearLine$title\n'),
(previousValue, testName) {
previousValue.writeln('$clearLine - $testName');
return previousValue;
},
);
stdout(lines.toString());
}
}

if (event is ExitTestEvent) {
Expand Down

0 comments on commit aa93176

Please sign in to comment.