Add main_class attribute to android_local_test.

This is currently a no-op in bazel, as its restricted to the existing
com.google.testing.junit.runner.GoogleTestRunner

PiperOrigin-RevId: 968590656
Change-Id: I8d61a0b89d830e985dc591fcddb4a03b8fa7db8c
diff --git a/rules/android_local_test/attrs.bzl b/rules/android_local_test/attrs.bzl
index c8b9aa2..7abc4c3 100644
--- a/rules/android_local_test/attrs.bzl
+++ b/rules/android_local_test/attrs.bzl
@@ -198,6 +198,15 @@
                 The test class needs to be annotated with `org.junit.runner.RunWith`.
                 """,
             ),
+            main_class = attr.string(
+                doc = """
+                The main class to execute in the generated test stub.
+                """,
+                default = "com.google.testing.junit.runner.BazelTestRunner",
+                values = [
+                    "com.google.testing.junit.runner.BazelTestRunner",
+                ],
+            ),
             _runfiles_root_prefix = attr.label(
                 doc = """
                 A directory prefix that ends with a slash.
diff --git a/rules/android_local_test/impl.bzl b/rules/android_local_test/impl.bzl
index 67e57de..a6094cd 100644
--- a/rules/android_local_test/impl.bzl
+++ b/rules/android_local_test/impl.bzl
@@ -47,7 +47,6 @@
 visibility(PROJECT_VISIBILITY)
 
 JACOCOCO_CLASS = "com.google.testing.coverage.JacocoCoverageRunner"
-TEST_RUNNER_CLASS = "com.google.testing.junit.runner.BazelTestRunner"
 
 # JVM processes for android_local_test targets are typically short lived. By
 # using TieredStopAtLevel=1, aggressive JIT compilations are avoided, which is
@@ -142,12 +141,14 @@
         [get_android_toolchain(ctx).testsupport]
     )
 
+    target_runner_class = ctx.attr.main_class
+
     if ctx.configuration.coverage_enabled:
         deps.append(get_android_toolchain(ctx).jacocorunner)
         java_start_class = JACOCOCO_CLASS
-        coverage_start_class = TEST_RUNNER_CLASS
+        coverage_start_class = target_runner_class
     else:
-        java_start_class = TEST_RUNNER_CLASS
+        java_start_class = target_runner_class
         coverage_start_class = None
 
     java_info = java.compile_android(