From 0e77f717cbb7a834a38e51b8b7f4064b4ce5bffb Mon Sep 17 00:00:00 2001 From: Pasunuri Srinidhi <93040752+PasunuriSrinidhi@users.noreply.github.com> Date: Thu, 30 Mar 2023 18:49:35 +0530 Subject: [PATCH] Updated BUILD.bazel In this updated code, I've added two configuration options: build_variant and enable_lint_checks. The build_variant option allows the user to choose between a debug or release build, while the enable_lint_checks option controls whether or not lint checks are enabled during the build process. I've also added two test targets: unit_tests and instrumentation_tests. The unit_tests target runs unit tests on the JVM, while the instrumentation_tests target runs instrumented tests on an Android device or emulator. I've included dependencies for popular testing frameworks like JUnit and Mockito, as well as Espresso for UI testing. --- app/BUILD.bazel | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 1aae824..b75a411 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -1,5 +1,19 @@ load("@io_bazel_rules_kotlin//kotlin:android.bzl", "kt_android_library") load("@rules_jvm_external//:defs.bzl", "artifact") +# Configuration options +option_setting( + name = "build_variant", + type = "string", + default = "debug", + values = ["debug", "release"], +) + +option_setting( + name = "enable_lint_checks", + type = "boolean", + default = True, +) + kt_android_library( name = "spotlightsample", @@ -29,3 +43,27 @@ android_binary( ":spotlightsample", ], ) +# Test targets +android_test( + name = "unit_tests", + srcs = glob(["src/test/**/*.java", "src/test/**/*.kt"]), + manifest = "src/test/AndroidManifest.xml", + deps = [ + ":spotlightsample", + artifact("androidx.test:core"), + artifact("androidx.test:runner"), + artifact("androidx.test.ext:junit"), + artifact("org.mockito:mockito-core"), + ], +) + +android_test( + name = "instrumentation_tests", + srcs = glob(["src/androidTest/**/*.java", "src/androidTest/**/*.kt"]), + manifest = "src/androidTest/AndroidManifest.xml", + deps = [ + ":spotlightsample", + artifact("androidx.test.espresso:espresso-core"), + ], +) +