diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index fbd85c346f..2d0919bbad 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -238,13 +238,15 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { final Set _testFileUris = {}; + bool get isWeb => stringArg('platform') == 'chrome'; + @override Future> get requiredArtifacts async { final Set results = _isIntegrationTest // Use [DeviceBasedDevelopmentArtifacts]. ? await super.requiredArtifacts : {}; - if (stringArg('platform') == 'chrome') { + if (isWeb) { results.add(DevelopmentArtifact.web); } return results; @@ -357,11 +359,12 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { 'Could not parse -j/--concurrency argument. It must be an integer greater than zero.' ); } - if (_isIntegrationTest) { + + if (_isIntegrationTest || isWeb) { if (argResults!.wasParsed('concurrency')) { globals.printStatus( '-j/--concurrency was parsed but will be ignored, this option is not ' - 'supported when running Integration Tests.', + 'supported when running Integration Tests or web tests.', ); } // Running with concurrency will result in deploying multiple test apps @@ -471,7 +474,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts { concurrency: jobs, testAssetDirectory: testAssetDirectory, flutterProject: flutterProject, - web: stringArg('platform') == 'chrome', + web: isWeb, randomSeed: stringArg('test-randomize-ordering-seed'), reporter: stringArg('reporter'), fileReporter: stringArg('file-reporter'), diff --git a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart index ab57a98311..03f8ba075a 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/test_test.dart @@ -600,6 +600,25 @@ dev_dependencies: ProcessManager: () => FakeProcessManager.any(), }); + testUsingContext('Overrides concurrency when running web tests', () async { + final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0); + + final TestCommand testCommand = TestCommand(testRunner: testRunner); + final CommandRunner commandRunner = createTestCommandRunner(testCommand); + + await commandRunner.run(const [ + 'test', + '--no-pub', + '--concurrency=100', + '--platform=chrome', + ]); + + expect(testRunner.lastConcurrency, 1); + }, overrides: { + FileSystem: () => fs, + ProcessManager: () => FakeProcessManager.any(), + }); + testUsingContext('when running integration tests', () async { final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0); @@ -852,6 +871,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner { late DebuggingOptions lastDebuggingOptionsValue; String? lastFileReporterValue; String? lastReporterOption; + int? lastConcurrency; @override Future runTests( @@ -890,6 +910,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner { lastDebuggingOptionsValue = debuggingOptions; lastFileReporterValue = fileReporter; lastReporterOption = reporter; + lastConcurrency = concurrency; if (leastRunTime != null) { await Future.delayed(leastRunTime!);