@@ -10,6 +10,7 @@ import 'package:file/memory.dart';
1010import 'package:flutter_tools/src/base/common.dart' ;
1111import 'package:flutter_tools/src/base/file_system.dart' ;
1212import 'package:flutter_tools/src/base/logger.dart' ;
13+ import 'package:flutter_tools/src/base/platform.dart' ;
1314import 'package:flutter_tools/src/cache.dart' ;
1415import 'package:flutter_tools/src/commands/test.dart' ;
1516import 'package:flutter_tools/src/device.dart' ;
@@ -660,6 +661,60 @@ dev_dependencies:
660661 ]),
661662 });
662663
664+ testUsingContext ('Tests on github actions default to github reporter' , () async {
665+ final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner (0 );
666+
667+ final TestCommand testCommand = TestCommand (testRunner: testRunner);
668+ final CommandRunner <void > commandRunner = createTestCommandRunner (testCommand);
669+
670+ await commandRunner.run (const < String > [
671+ 'test' ,
672+ '--no-pub' ,
673+ ]);
674+
675+ expect (
676+ testRunner.lastReporterOption,
677+ 'github' ,
678+ );
679+ }, overrides: < Type , Generator > {
680+ FileSystem : () => fs,
681+ ProcessManager : () => FakeProcessManager .any (),
682+ Platform : () => FakePlatform (
683+ environment: < String , String > {
684+ 'GITHUB_ACTIONS' : 'true' ,
685+ },
686+ ),
687+ DeviceManager : () => _FakeDeviceManager (< Device > [
688+ FakeDevice ('ephemeral' , 'ephemeral' , type: PlatformType .android),
689+ ]),
690+ });
691+
692+ testUsingContext ('Tests default to compact reporter if not specified and not on Github actions' , () async {
693+ final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner (0 );
694+
695+ final TestCommand testCommand = TestCommand (testRunner: testRunner);
696+ final CommandRunner <void > commandRunner = createTestCommandRunner (testCommand);
697+
698+ await commandRunner.run (const < String > [
699+ 'test' ,
700+ '--no-pub' ,
701+ ]);
702+
703+ expect (
704+ testRunner.lastReporterOption,
705+ 'compact' ,
706+ );
707+ }, overrides: < Type , Generator > {
708+ FileSystem : () => fs,
709+ ProcessManager : () => FakeProcessManager .any (),
710+ Platform : () => FakePlatform (
711+ environment: < String , String > {}
712+ ),
713+ DeviceManager : () => _FakeDeviceManager (< Device > [
714+ FakeDevice ('ephemeral' , 'ephemeral' , type: PlatformType .android),
715+ ]),
716+ });
717+
663718 testUsingContext ('Integration tests given flavor' , () async {
664719 final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner (0 );
665720
@@ -789,6 +844,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
789844 Duration ? leastRunTime;
790845 bool ? lastEnableObservatoryValue;
791846 late DebuggingOptions lastDebuggingOptionsValue;
847+ String ? lastReporterOption;
792848
793849 @override
794850 Future <int > runTests (
@@ -824,6 +880,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
824880 }) async {
825881 lastEnableObservatoryValue = enableObservatory;
826882 lastDebuggingOptionsValue = debuggingOptions;
883+ lastReporterOption = reporter;
827884
828885 if (leastRunTime != null ) {
829886 await Future <void >.delayed (leastRunTime! );
0 commit comments