Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/src/commands/test/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class FlutterTestOptions {
required this.platform,
required this.reportOn,
required this.runSkipped,
required this.flavor,
required this.rest,
});

Expand Down Expand Up @@ -63,6 +64,7 @@ class FlutterTestOptions {
final platform = argResults['platform'] as String?;
final reportOn = argResults['report-on'] as String?;
final runSkipped = argResults['run-skipped'] as bool;
final flavor = argResults['flavor'] as String?;
final rest = argResults.rest;

return FlutterTestOptions._(
Expand All @@ -84,6 +86,7 @@ class FlutterTestOptions {
platform: platform,
reportOn: reportOn,
runSkipped: runSkipped,
flavor: flavor,
rest: rest,
);
}
Expand Down Expand Up @@ -144,6 +147,9 @@ class FlutterTestOptions {
/// Whether to run skipped tests instead of skipping them.
final bool runSkipped;

/// The flavor to build for testing.
final String? flavor;

/// The remaining arguments passed to the test command.
final List<String> rest;
}
Expand Down Expand Up @@ -314,6 +320,13 @@ class TestCommand extends Command<int> {
'run-skipped',
help: 'Run skipped tests instead of skipping them.',
negatable: false,
)
..addOption(
'flavor',
help:
'Build a custom app flavor as defined by platform-specific build '
'setup. Supports the use of product flavors in Android Gradle '
'scripts, and the use of custom Xcode schemes.',
);
}

Expand Down Expand Up @@ -383,6 +396,7 @@ This command should be run from the root of your Flutter project.''');
if (options.updateGoldens) '--update-goldens',
if (options.failFast) '--fail-fast',
if (options.runSkipped) '--run-skipped',
if (options.flavor != null) ...['--flavor', options.flavor!],
if (options.platform != null) ...['--platform', options.platform!],
if (options.dartDefine != null)
for (final value in options.dartDefine!) '--dart-define=$value',
Expand Down
17 changes: 17 additions & 0 deletions test/src/commands/test/test_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const expectedTestUsage = [
' --platform=<chrome|vm|android|ios> The platform to run tests on. \n'
' --report-on=<lib/> An optional file path to report coverage information to. This should be a path relative to the current working directory.\n'
' --run-skipped Run skipped tests instead of skipping them.\n'
' --flavor Build a custom app flavor as defined by platform-specific build setup. Supports the use of product flavors in Android Gradle scripts, and the use of custom Xcode schemes.\n'
'\n'
'Run "very_good help" to see global options.',
];
Expand Down Expand Up @@ -131,6 +132,7 @@ void main() {
when<dynamic>(() => argResults['platform']).thenReturn(null);
when<dynamic>(() => argResults['report-on']).thenReturn(null);
when<dynamic>(() => argResults['run-skipped']).thenReturn(false);
when<dynamic>(() => argResults['flavor']).thenReturn(null);
when<dynamic>(
() => argResults['collect-coverage-from'],
).thenReturn('imports');
Expand Down Expand Up @@ -795,6 +797,21 @@ void main() {
},
);

test('completes normally --flavor development', () async {
when<dynamic>(() => argResults['flavor']).thenReturn('development');
final result = await testCommand.run();
expect(result, equals(ExitCode.success.code));
verify(
() => flutterTest(
optimizePerformance: true,
arguments: ['--flavor', 'development', ...defaultArguments],
logger: logger,
stdout: logger.write,
stderr: logger.err,
),
).called(1);
});

test('completes normally --run-skipped', () async {
when<dynamic>(() => argResults['run-skipped']).thenReturn(true);
final result = await testCommand.run();
Expand Down
Loading