Skip to content

Instantly share code, notes, and snippets.

@Shebella
Created July 16, 2015 03:40
Show Gist options
  • Save Shebella/4daccdf9d43629d9c444 to your computer and use it in GitHub Desktop.
Save Shebella/4daccdf9d43629d9c444 to your computer and use it in GitHub Desktop.
AndroidGradleTemplate Status Coverage Status
Gradle + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock + JaCoCo
Works with the following Configurations:
Multiple Modules
Multiple Flavors
Android Libraries
Technologies used:
Build Tools:
Name Version Description
Gradle 2.4 Gradle build system
Android Gradle Build Tools 1.2.3 Official Gradle Plugin
Android SDK 22 Official SDK
Android SDK Build Tools 22.0.1 Official Build Tools
Android Studio or 1.2+ Official IDE
Intellij 14.1.3+ Intellij IDE
Android Libraries:
Name Version Description
Android Support-v4 22.0.1 Support Library API 4+
Android AppCompat-v7 22.0.1 Support Library API 7+
Android Google Play Services 7.3.0 Admob, Analytics, etc
Testing Frameworks:
Name Version Description
JUnit 4.12 Java Unit Testing Framework
Hamcrest 1.3 Matchers for Unit Tests
Espresso 2.1 Google's New Instrumentation Framework
Robolectric 3.0-RC3 Unit Testing Framework
Mockito 1.10.19 Mocking Framework
EasyMock 3.3.1 Mocking Framework
PowerMock 1.6.2 Mocking Framework(static method support)
Reporting Plugins:
Name Version Description
JaCoCo 0.7.4.201502262128 JaCoCo Test Coverage
Coveralls N/A Hosts test reports published from TravisCI
Continuous Integration:
Name Description
TravisCI Build Server(Builds, Tests, Publishes reports to Coveralls)
Publishing to Google Play:
Name Version Description
Gradle-play-publisher 1.1.0 Publishes your app to Google Play
Getting Started:
View JUnit and Hamcrest Tests
View Robolectric Activity Tests
View Robolectric Fragment Tests
View EasyMock/PowerMock Tests
Android Studio or Intellij Support(Simple):
Import/Open this project with Android Studio/Intellij(click on build.gradle)
Instrumentation Tests:
Change the Build Varient Test Artifact to Instrumentation Tests
Right click an instrumentation test located in src/main/androidTest and click test
Unit Tests:
Change the Build Variant Test Artifact to Unit Tests
Right click a unit test located in src/main/test and click test
Comand Line(Advanced):
Clone with Git:
git clone https://github.com/jaredsburrows/AndroidGradleTemplate.git
cd AndroidGradleTemplate
Installing/Running with Gradle:
Install the debug flavor on your Android Device:
gradlew installDebug
Install and Run the debug flavor on your Android Device:
gradlew runDebug
Running Instrumentation/Espresso Tests with Gradle:
Run all instrumentation tests in all flavors:
gradlew connectedAndroidTest
Running Unit Tests with Gradle:
Run all unit tests in all flavors:
gradlew test
Run a single unit test in all flavors:
gradlew test --tests="*MainActivityTest*"
Run all unit debug flavor tests:
gradlew testDebug
Run a single unit test in the debug flavor:
gradlew testDebug --tests="*MainActivityTest*"
Run a single unit test in the debug flavor with Jacoco test reports:
gradlew testDebug --tests="*MainActivityTest*" jacocoTestReport
License
Copyright (C) 2015 AndroidGradleTemplate by Jared Burrows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment