@@ -10,6 +10,7 @@ import 'package:file/memory.dart';
10
10
import 'package:flutter_tools/src/base/common.dart' ;
11
11
import 'package:flutter_tools/src/base/file_system.dart' ;
12
12
import 'package:flutter_tools/src/base/logger.dart' ;
13
+ import 'package:flutter_tools/src/base/platform.dart' ;
13
14
import 'package:flutter_tools/src/cache.dart' ;
14
15
import 'package:flutter_tools/src/commands/test.dart' ;
15
16
import 'package:flutter_tools/src/device.dart' ;
@@ -660,6 +661,60 @@ dev_dependencies:
660
661
]),
661
662
});
662
663
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
+
663
718
testUsingContext ('Integration tests given flavor' , () async {
664
719
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner (0 );
665
720
@@ -789,6 +844,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
789
844
Duration ? leastRunTime;
790
845
bool ? lastEnableObservatoryValue;
791
846
late DebuggingOptions lastDebuggingOptionsValue;
847
+ String ? lastReporterOption;
792
848
793
849
@override
794
850
Future <int > runTests (
@@ -824,6 +880,7 @@ class FakeFlutterTestRunner implements FlutterTestRunner {
824
880
}) async {
825
881
lastEnableObservatoryValue = enableObservatory;
826
882
lastDebuggingOptionsValue = debuggingOptions;
883
+ lastReporterOption = reporter;
827
884
828
885
if (leastRunTime != null ) {
829
886
await Future <void >.delayed (leastRunTime! );
0 commit comments