Skip to content

Commit

Permalink
feat(test): imply --coverage when --min-coverage is supplied (#367)
Browse files Browse the repository at this point in the history
  • Loading branch information
willhlas authored May 5, 2022
1 parent a828288 commit 666b513
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/commands/test/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ This command should be run from the root of your Flutter project.''',
progress: _logger.progress,
stdout: _logger.write,
stderr: _logger.err,
collectCoverage: collectCoverage,
collectCoverage: collectCoverage || minCoverage != null,
minCoverage: minCoverage,
excludeFromCoverage: excludeFromCoverage,
randomSeed: randomSeed,
Expand Down
18 changes: 18 additions & 0 deletions test/src/commands/test/test_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ void main() {
).called(1);
});

test('enables coverage collection when --min-coverage is supplied',
() async {
when<dynamic>(() => argResults['min-coverage']).thenReturn('0');
final result = await testCommand.run();
expect(result, equals(ExitCode.success.code));
verify(
() => flutterTest(
optimizePerformance: true,
collectCoverage: true,
arguments: defaultArguments,
minCoverage: 0,
progress: logger.progress,
stdout: logger.write,
stderr: logger.err,
),
).called(1);
});

test('fails when coverage not met', () async {
when<dynamic>(() => argResults['coverage']).thenReturn(true);
when<dynamic>(() => argResults['min-coverage']).thenReturn('100');
Expand Down

0 comments on commit 666b513

Please sign in to comment.