@@ -430,7 +430,8 @@ void main() {
430430 ],
431431 );
432432
433- await runCapturingPrint (runner, < String > ['native-test' , '--android' ]);
433+ await runCapturingPrint (
434+ runner, < String > ['native-test' , '--android' , '--no-unit' ]);
434435
435436 final Directory androidFolder =
436437 plugin.childDirectory ('example' ).childDirectory ('android' );
@@ -467,7 +468,8 @@ void main() {
467468 ],
468469 );
469470
470- await runCapturingPrint (runner, < String > ['native-test' , '--android' ]);
471+ await runCapturingPrint (
472+ runner, < String > ['native-test' , '--android' , '--no-unit' ]);
471473
472474 // Nothing should run since those files are all
473475 // integration_test-specific.
@@ -641,7 +643,11 @@ void main() {
641643 );
642644
643645 final List <String > output = await runCapturingPrint (
644- runner, < String > ['native-test' , '--android' ]);
646+ runner, < String > ['native-test' , '--android' ],
647+ errorHandler: (Error e) {
648+ // Having no unit tests is fatal, but that's not the point of this
649+ // test so just ignore the failure.
650+ });
645651
646652 expect (
647653 output,
@@ -654,7 +660,7 @@ void main() {
654660 ]));
655661 });
656662
657- test ('fails when a test fails' , () async {
663+ test ('fails when a unit test fails' , () async {
658664 final Directory pluginDir = createFakePlugin (
659665 'plugin' ,
660666 packagesDir,
@@ -695,6 +701,84 @@ void main() {
695701 );
696702 });
697703
704+ test ('fails when an integration test fails' , () async {
705+ final Directory pluginDir = createFakePlugin (
706+ 'plugin' ,
707+ packagesDir,
708+ platformSupport: < String , PlatformDetails > {
709+ kPlatformAndroid: const PlatformDetails (PlatformSupport .inline)
710+ },
711+ extraFiles: < String > [
712+ 'example/android/gradlew' ,
713+ 'example/android/app/src/test/example_test.java' ,
714+ 'example/android/app/src/androidTest/IntegrationTest.java' ,
715+ ],
716+ );
717+
718+ final String gradlewPath = pluginDir
719+ .childDirectory ('example' )
720+ .childDirectory ('android' )
721+ .childFile ('gradlew' )
722+ .path;
723+ processRunner.mockProcessesForExecutable[gradlewPath] = < io.Process > [
724+ MockProcess (), // unit passes
725+ MockProcess (exitCode: 1 ), // integration fails
726+ ];
727+
728+ Error ? commandError;
729+ final List <String > output = await runCapturingPrint (
730+ runner, < String > ['native-test' , '--android' ],
731+ errorHandler: (Error e) {
732+ commandError = e;
733+ });
734+
735+ expect (commandError, isA <ToolExit >());
736+
737+ expect (
738+ output,
739+ containsAllInOrder (< Matcher > [
740+ contains ('plugin/example integration tests failed.' ),
741+ contains ('The following packages had errors:' ),
742+ contains ('plugin' )
743+ ]),
744+ );
745+ });
746+
747+ test ('fails if there are no unit tests' , () async {
748+ createFakePlugin (
749+ 'plugin' ,
750+ packagesDir,
751+ platformSupport: < String , PlatformDetails > {
752+ kPlatformAndroid: const PlatformDetails (PlatformSupport .inline)
753+ },
754+ extraFiles: < String > [
755+ 'example/android/gradlew' ,
756+ 'example/android/app/src/androidTest/IntegrationTest.java' ,
757+ ],
758+ );
759+
760+ Error ? commandError;
761+ final List <String > output = await runCapturingPrint (
762+ runner, < String > ['native-test' , '--android' ],
763+ errorHandler: (Error e) {
764+ commandError = e;
765+ });
766+
767+ expect (commandError, isA <ToolExit >());
768+
769+ expect (
770+ output,
771+ containsAllInOrder (< Matcher > [
772+ contains ('No Android unit tests found for plugin/example' ),
773+ contains (
774+ 'No unit tests ran. Plugins are required to have unit tests.' ),
775+ contains ('The following packages had errors:' ),
776+ contains ('plugin:\n '
777+ ' No unit tests ran (use --exclude if this is intentional).' )
778+ ]),
779+ );
780+ });
781+
698782 test ('skips if Android is not supported' , () async {
699783 createFakePlugin (
700784 'plugin' ,
@@ -713,7 +797,7 @@ void main() {
713797 );
714798 });
715799
716- test ('skips when running no tests' , () async {
800+ test ('skips when running no tests in integration-only mode ' , () async {
717801 createFakePlugin (
718802 'plugin' ,
719803 packagesDir,
@@ -723,12 +807,11 @@ void main() {
723807 );
724808
725809 final List <String > output = await runCapturingPrint (
726- runner, < String > ['native-test' , '--android' ]);
810+ runner, < String > ['native-test' , '--android' , '--no-unit' ]);
727811
728812 expect (
729813 output,
730814 containsAllInOrder (< Matcher > [
731- contains ('No Android unit tests found for plugin/example' ),
732815 contains ('No Android integration tests found for plugin/example' ),
733816 contains ('SKIPPING: No tests found.' ),
734817 ]),
0 commit comments