Skip to content

Gradle + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock + JaCoCo

License

Notifications You must be signed in to change notification settings

adhiamboperes/android-bazel-java-app-template

 
 

Repository files navigation

Android Bazel Java App Template

License Build Twitter Follow

Bazel + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock

Technologies used:

Build Tools:

Name Description
Bazel Bazel build system
Android SDK Official SDK
Android SDK Build Tools Official Build Tools
Android Studio or Official IDE
Intellij Intellij IDE

Testing Frameworks:

Name Description
Espresso Instrumentation Framework
Robolectric Unit Testing Framework

Getting Started:

Android Studio or Intellij Support (Simple):

  • Import/Open this project with Android Studio/Intellij
    1. Install the Bazel plugin.
    2. In the project selection dialog, click "Import Bazel Project".
    3. For the project view, select "Create from scratch".
    4. Click "Finish".

Building and Running

This project builds with Bazel, Bazel's Android rules, and the Android Build tools.

Build the APK:

$ bazel build //src/main:template_app

Install the APK:

$ bazel mobile-install //src/main:template_app

or:

$ bazel build //src/main:template_app && adb install bazel-bin/src/main/template_app.apk

Run the App:

$ bazel mobile-install //src/main:template_app --start_app

Note: Expect the first build to take a few minutes, depending on your machine, because Bazel's cache is clean. After Bazel downloads and builds the app once, subsequent builds will be much faster.

Testing

Running the Unit Tests:

The Junit and Robolectric tests run on the JVM, no need for emulators or real devices.

$ bazel test //src/test:all

Run a single unit test (android_local_test):

$ bazel test //src/test:play_services_utils_test

Get the list of all android_local_test targets:

$ bazel query 'kind(android_local_test, //src/test/...)'

Running the Instrumentation Tests:

The Espresso instrumentation tests run on the device. There is no need to launch an emulator, Bazel will do it automatically as part of the instrumentation test.

This is currently only supported on Linux.

$ bazel test //src/androidTest:main_activity_test

Read the Bazel docs here.

About

Gradle + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock + JaCoCo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 69.9%
  • Starlark 30.1%