diff --git a/script/tool/lib/src/firebase_test_lab_command.dart b/script/tool/lib/src/firebase_test_lab_command.dart index fa2d1e525fcd..5d2ab937c351 100644 --- a/script/tool/lib/src/firebase_test_lab_command.dart +++ b/script/tool/lib/src/firebase_test_lab_command.dart @@ -360,8 +360,16 @@ class FirebaseTestLabCommand extends PackageLoopingCommand { .where((FileSystemEntity entity) => entity is File) .cast() .any((File file) { - return file.basename.endsWith('.java') && - file.readAsStringSync().contains('@RunWith(FlutterTestRunner.class)'); + if (file.basename.endsWith('.java')) { + return file + .readAsStringSync() + .contains('@RunWith(FlutterTestRunner.class)'); + } else if (file.basename.endsWith('.kt')) { + return file + .readAsStringSync() + .contains('@RunWith(FlutterTestRunner::class)'); + } + return false; }); } } diff --git a/script/tool/test/firebase_test_lab_command_test.dart b/script/tool/test/firebase_test_lab_command_test.dart index 2bed0db0f085..067bf9cbaf58 100644 --- a/script/tool/test/firebase_test_lab_command_test.dart +++ b/script/tool/test/firebase_test_lab_command_test.dart @@ -564,6 +564,48 @@ public class MainActivityTest { ); }); + test('supports kotlin implementation of integration_test runner', () async { + const String kotlinTestFileRelativePath = + 'example/android/app/src/androidTest/MainActivityTest.kt'; + final RepositoryPackage plugin = + createFakePlugin('plugin', packagesDir, extraFiles: [ + 'test/plugin_test.dart', + 'example/integration_test/foo_test.dart', + 'example/android/gradlew', + kotlinTestFileRelativePath, + ]); + + // Kotlin equivalent of the test runner + childFileWithSubcomponents( + plugin.directory, p.posix.split(kotlinTestFileRelativePath)) + .writeAsStringSync(''' +@DartIntegrationTest +@RunWith(FlutterTestRunner::class) +class MainActivityTest { + @JvmField @Rule var rule = ActivityTestRule(MainActivity::class.java) +} +'''); + + final List output = await runCapturingPrint( + runner, + [ + 'firebase-test-lab', + '--results-bucket=a_bucket', + '--device', + 'model=redfin,version=30', + ], + ); + + expect( + output, + containsAllInOrder([ + contains('Running for plugin'), + contains('Testing example/integration_test/foo_test.dart...'), + contains('Ran for 1 package') + ]), + ); + }); + test('skips packages with no android directory', () async { createFakePackage('package', packagesDir, extraFiles: [ 'example/integration_test/foo_test.dart',